Has anyone been successful in implementing the Dynamic Label feature for an Action button? I have tried several variations of populating the label, but the button remains blank. I am using VFE v 5.04 and the help says that this feature is supported. I'm wondering if I'm doing something wrong.
Thanks
I have been doing this for awhile and I have never had any trouble, same VFE version, CPS 10.1.3. I declare the variable as a global variable in the white space, and then also write code to determine what the label is, something like this -
{!global _dynamiclabel}
{!if SomethingToEvaluate == "TRUE" then
_dynamiclabel = "Option1"
else
_dynamiclabel = "Option2"
endif}
The second part could be just about anything, just make sure that whatever code determines the label is called with a '!' to run on form open.
What I am doing is, depending upon what value a certain document variable has determines what label text I want. I have a function defined as follows in a function library:
GetContactByLabel(CallType)
{
cond
case CallType == "Walk-In"
return "Entered By"
case CallType == "Incoming Call"
return "Call Taken By"
case CallType == "Outgoing Call" or CallType == "Outreach Call"
return "Call Placed By"
else
return ""
endcond
}
In the "Label" section of the Action button I have the following MEL code:
{GetContactByLabel(document.CALL_SOURCE)}
document.CALL_SOURCE is connected to a Radio Button control with the four choices listed above in the function.
So I found part of the problem. For some reason the label font of the Action button was set to Arial:0 for whatever reason. After resetting that to Arial:8, the only way that the text will show up on the button is if I actually click on the button. For some reason it is not refreshing as the value of document.CALL_SOURCE changes. In the MEL trace, I can see my function fire when I change the value of document.CALL_SOURCE. Kinda scratching my head now.
I would try this -
{!global _CALL_SOURCE}
GetContactByLabel(CallType)
{
cond
case CallType == "Walk-In"
return "Entered By"
case CallType == "Incoming Call"
return "Call Taken By"
case CallType == "Outgoing Call" or CallType == "Outreach Call"
return "Call Placed By"
else
return ""
endcond
}
In the "Label" section of the Action button I have the following MEL code:
{!_CALL_SOURCE = GetContactByLabel(document.CALL_SOURCE)}
and make _CALL_SOURCE the dynamic label, this method has always worked for me
try this in the code window:
{global gblVar}
{gblVar = GetContactByLabel(document.CALL_SOURCE)}
and use gblVar in your Label field.
by calling {GetContactByLabel(document.CALL_SOURCE)} in your Label field, it returns the correct label, but it's not storing it anywhere, so when it comes time for the form to refresh, the value is gone, but if it's stored in the global variable, it's there at refresh time.
Michael's idea works too. It just forces the function to be called every time the action button is refreshed, where my code only calls the function when the radio button changes.
Great suggestions and I've tried storing it in a document variable and a global variable, but it won't refresh until I click the button. Very frustrating!
Ok. I have an update. So using the global variable works...to an extent. I put the Action button in a Visibility control which seemed to help with the refresh the first time you select a choice, populating document.CALL_SOURCE. On subsequent updates to the document.CALL_SOURCE variable, the Action button label will not refresh unless you click the button.
I'm getting closer, but it's not perfect, because I just know it will create confusion for the users if they realize they clicked the wrong call source and then click another choice and the button does not update.
I think I need to come up with some intermediary step that resets the global variable then sets it to the new choice. I will post back the results for the good of the group.
Thanks again for all your help. VFE and MEL can be so challenging with their limitations. I hope someday GE will give us some sort of Business Objects where we can manipulate data in custom apps outside of the EMR.
So, in my version of CPS 10.1.3, if you have a button on the same page as the radio button that controls the label, the label will not change until the page is refreshed. I got it to work by using JUMP_TO_TAB(), once to leave the page and once to come back, keyed off the variable change, in this case a radio button. Not ideal but it did work to refresh the page and update the label.