Page 1 of 1
Set_Error in VLFONE
Posted: Fri Feb 12, 2021 10:09 am
by ESODevKJ
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!
Re: Set_Error in VLFONE
Posted: Fri Feb 12, 2021 11:15 am
by Dino
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
Re: Set_Error in VLFONE
Posted: Fri Feb 12, 2021 11:27 am
by Dino
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
Re: Set_Error in VLFONE
Posted: Sat Feb 20, 2021 3:16 am
by ESODevKJ
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.