VLF-ONE SWITCH question
Posted: Wed Aug 23, 2017 7:43 am
Use Case:
Two Business Objects share a command handler.
The command handler adds records to a file(s) and adds an instance to BO #1 (this command handler is attached to a command for both BO #1 and BO #2).
After adding the record(s) we clear the instance list for BO #1, switch to it from BO #2 if we are in BO #1, load the instance list with the records just added, then open a command handler for BO #2 (probably the default command) and load the current instance.
This would seem to be a fairly common scenario, but it was a little tricky working out how it works.
We have this.
BO #2 Command Handler
insert data
Why?
The Wait(True) doesn't actually seem to wait. So when you attempt the signal, the Filter for BO#1 doesn't see the event.
If you put in a slight delay before doing the signal, then the filter for BO#1 can see the event.
Is this a bug perhaps?
BO#1 Filter
This is just a test case.
Employee is BO#1
Departments is BO#2
I named the objects here BO1 and BO2 in the code for clarity
So here there is a command Executedefaultcmd(True) on the addtolist, but it doesn't appear to do anything.
To open up the command handler programmatically, one needs to execute a switch here and use the EXECUTE command
This seems to work pretty well except for the following.
The timer seems like a hack.
The Executedefaultcmd doesn't appear to do anything.
QUESTIONS
Is this best practice for this use case?
Is the Executedefaultcmd not doing anything a bug?
Is the WAIT(True) not appearing to do anything a bug, or are we misunderstanding what it is doing?
NOTE: This is using EPC1410343
Two Business Objects share a command handler.
The command handler adds records to a file(s) and adds an instance to BO #1 (this command handler is attached to a command for both BO #1 and BO #2).
After adding the record(s) we clear the instance list for BO #1, switch to it from BO #2 if we are in BO #1, load the instance list with the records just added, then open a command handler for BO #2 (probably the default command) and load the current instance.
This would seem to be a fairly common scenario, but it was a little tricky working out how it works.
We have this.
BO #2 Command Handler
insert data
Code: Select all
.
insert records
#AVFRAMEWORKMANAGER.avSwitch Toobjectnamed(BO1) Caller(#COM_OWNER) Wait(True)
* #COM_OWNER.avSignalEvent Withid(Load_Opportunity) To(APPLICATION) Sendainfo1(#thekeyjustadded) - this doesn't work comment out
#Timer1.INTERVAL := 100
#Timer1.START
.
Evtroutine Handling(#Timer1.Tick)
#Timer1.Stop
#COM_OWNER.avSignalEvent Withid(Load_Opportunity) To(APPLICATION) Sendainfo1(#thekeyjustadded)
Endroutine
The Wait(True) doesn't actually seem to wait. So when you attempt the signal, the Filter for BO#1 doesn't see the event.
If you put in a slight delay before doing the signal, then the filter for BO#1 can see the event.
Is this a bug perhaps?
BO#1 Filter
This is just a test case.
Employee is BO#1
Departments is BO#2
I named the objects here BO1 and BO2 in the code for clarity
Code: Select all
Evtroutine Handling(#Com_owner.avEvent) Withid(#EventId) Withainfo1(#pEmployeeKey)
Define_Com Class(#A106S.Find) Name(#Find)
Group_By Name(#xEmployee) Fields(#xEmployeeIdentification #xEmployeeTitle #xEmployeeSurname #xEmployeeGivenNames #xEmployeeDateofBirth #xEmployeeGender #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeCountry #xEmployeeHomeTelephone #xEmployeeBusinessTelephone #xEmployeeMobilePhone #xEmployeeSalary #xEmployeeStartDate #xEmployeeTerminationDate #xDepartmentCode)
#vf_elIdn := #EventId.Value
Case (#vf_elIDN)
When Value_Is(= Load_Opportunity)
#avListManager.ClearList
#xEmployeeIdentification := #pEmployeeKey
#Find.Execute Xemployeeidentification(#xEmployeeIdentification) Xemployee(#xEmployee)
#UF_VISID1u := #xEmployeeIdentification
#UF_VISID2u := #xEmployeeSurname
#avListManager.AddtoList Visualid1(#UF_VISID1u) Visualid2(#UF_VISID2u) Akey1(#xEmployeeIdentification) Acolumn1(#xEmployeeGivenNames) Setascurrent(True) Select(True) Executedefaultcmd(True)
#AVFRAMEWORKMANAGER.avSwitch Toobjectnamed(BO1) Caller(#COM_OWNER) Execute(COMMAND_DETAILS)
Endcase
To open up the command handler programmatically, one needs to execute a switch here and use the EXECUTE command
This seems to work pretty well except for the following.
The timer seems like a hack.
The Executedefaultcmd doesn't appear to do anything.
QUESTIONS
Is this best practice for this use case?
Is the Executedefaultcmd not doing anything a bug?
Is the WAIT(True) not appearing to do anything a bug, or are we misunderstanding what it is doing?
NOTE: This is using EPC1410343