Set_Error in VLFONE

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
ESODevKJ
Posts: 18
Joined: Tue Nov 10, 2020 9:07 am

Set_Error in VLFONE

Post by ESODevKJ » Fri Feb 12, 2021 10:09 am

In my server module, I have a check for error for a field:

Code: Select all

Begincheck

Change Field(#VALID) To(0)
Change Field(#WKSTR30) To(#ADDRNM)
Execute Subroutine(CHK_STR) With_Parms(#WKSTR30 #VALID)
If Cond('#VALID > 0')
Set_Error For_Field(#ADDRNM) Msgid(ESO8797) Msgf(ESOMSGS)
Endif
Endcheck
My issue is, I can't figure out how to have that error message appear on the web browser. I used a Lansa Simple CRUD and a different error message appears when I try to Update an incorrect entry, but I can't seem to follow the logic in the CRUD for the customized parts I am working on now.

Thanks!

User avatar
Dino
Posts: 95
Joined: Fri Jul 19, 2019 7:49 am
Location: Tail of the Dragon, Robbinsville, NC
Contact:

Re: Set_Error in VLFONE

Post by Dino » Fri Feb 12, 2021 11:15 am

I have noticed that the ENDCHECK in the servermodule, is not making IO$STS to be VE.

So, if you are working in the PUTDATA section, something like this will work, while, I hate to use GOTO for this:

Code: Select all

* ---------------------------------------------------------------------------------
Srvroutine Name(PutData) Session(*REQUIRED)
List_Map For(*INPUT) List(#EditableDataItems)
Field_Map For(*OUTPUT) Field(#ServerModuleResult)

Define_Com Class(#vf_elretc) Name(#Io_Status)
Define_Com Class(#Prim_dc.UnicodeString) Name(#ResultMessage)


* Invoke the server manager to set up the execution context for this server routine
#ServerSystemManager.InitializeServiceRoutine Persistentstring1(#Persistent_ApplicationString1) Persistentstring2(#Persistent_ApplicationString2) Persistentstring3(#Persistent_ApplicationString3) Persistentstring4(#Persistent_ApplicationString4) Persistentstring5(#Persistent_ApplicationString5) Event_Component(#COM_OWNER) Persistent_Eventdetails(#Persistent_EventDetails)

* Process the request
Get_Entry Number(1) From_List(#EditableDataItems)

Begincheck
Rangecheck Field(#SALARY) Range((50000 90000)) Msgtxt('The valid range for Salary is 50k to 150k in this program')
Endcheck If_Error(PER)
Goto Label(OK)
PER:
#IO_STATUS := VE
OK: 
If (#IO_STATUS *NE VE)
Check_For In_File(PSLMST) With_Key(#XG_AccessKeys) Io_Status(#Io_Status) Io_Error(*NEXT)
Case (#Io_Status)
When (= EQ)
Update Fields(#EditableDataItems) In_File(PSLMST) With_Key(#XG_AccessKeys) Io_Status(#Io_Status) Io_Error(*NEXT)
When (= NE)
Insert Fields(#EditableDataItems) To_File(PSLMST) Io_Status(#Io_Status) Io_Error(*NEXT)
Endcase

Case (#Io_Status)
When (= OK)
#ResultMessage := *MTXTUF_MSG_0005.Substitute( #SingularName #Com_Self.VisibleIdentification )
#ServerModuleResult := True
When (= VE)
#ResultMessage := *MTXTUF_MSG_0006.Substitute( #SingularName #Com_Self.VisibleIdentification )
Otherwise
#ResultMessage := *MTXTUF_MSG_0007.Substitute( #SingularName #Com_Self.VisibleIdentification #Io_Status )
Endcase

Message Msgtxt(#ResultMessage)
Endif

* Invoke the server manager to clean up and finalize the execution context for this server routine
#ServerSystemManager.TerminateServiceRoutine Event_Component(#COM_OWNER)

Endroutine
On the other hand, in the command handler there is a note that additional validations should be made there, but cant find any documentation for that, and if you want to use a begincheck-endcheck area, well, that is not supported at that level, you need to be in a server module:

Code: Select all

* ---------------------------------------------------------------------------------
Mthroutine Name(CheckClientSideValidation) Access(*PRIVATE)
Define_Map For(*INPUT) Class(#PRIM_ALPH) Name(#ForOperation)
Define_Map For(*RESULT) Class(#Prim_Boln) Name(#AllValid)
#COM_OWNER.avValidateAllTrackedMDControls Foroperation(#ForOperation) Allvalid(#AllValid)
* Add any additional client side validation logic here

Endroutine

User avatar
Dino
Posts: 95
Joined: Fri Jul 19, 2019 7:49 am
Location: Tail of the Dragon, Robbinsville, NC
Contact:

Re: Set_Error in VLFONE

Post by Dino » Fri Feb 12, 2021 11:27 am

And here is other post where is discussed how to use the avValidateAllTrackedMDControls if you want to have message error to appear under the field with the error.

viewtopic.php?t=1871

ESODevKJ
Posts: 18
Joined: Tue Nov 10, 2020 9:07 am

Re: Set_Error in VLFONE

Post by ESODevKJ » Sat Feb 20, 2021 3:16 am

Thanks for the ideas.

I ended up having to create a reusable part that I dropped on the view container and any messages that the server module returned were fed into the reusable part after the click event.

If anyone else is having an issue with this, happy to share what I did.

Post Reply