Felt like tinkering some more with the provideX 'Text' and 'Image' mnemonics method and came up with a good routine.
The attached script contains two methods for illustrative purposes.
Method 1 uses a sourced display-only UDF as the placeholder for your dynamic value.
Method 2 dynamically draws text on the screen. This is more flexible with positioning, font style, font size, and font, color.
The script still needs to be attached to the table post-read and UI post-load if you want the dynamic text displayed consistently when a record is read and when the user switches tabs.
' Make sure "Allow External Access" is checked.
If IsObject(oSession) Then
' Make sure task's UI object is present.
' You can also add a check for the SY_Session.StartProgram property if you want to further restrict this to a specific task.
If oScript.UIObj > 0 Then
' Check the current folder name to make sure this executes while on the correct tab.
' You can also add a check for oScript.GetScreenName() to further restrict this to a specific panel library.
If UCase(oSession.AsObject(oScript.UIObj).GetFolderName()) = UCase("pAddl") Then
' Get the value you want to use.
sItemCodeDesc = "" : oBusObj.GetValue "ItemCodeDesc$", sItemCodeDesc
' Method 1, use a sourced display-only udf. Double quotes must be escaped by doubling them up.
oSession.AsObject(oScript.UIObj).SetVar "CMD_STR$", "X ALB_Main_ItemCode$=""" & Replace(sItemCodeDesc, """", """""") & """"
' Method 2, use fonted text with a 'Image' group. You need to specify coordinates and can also change the color too. Double quotes must be escaped by doubling them up.
oScript.Execute "Print 'Image'(Delete ""sItemCodeDescText"")"
If sItemCodeDesc <> "" Then
oScript.Execute "sItemCodeDescText$='Red'+'Text'(@X(47),@Y(24.5),""" & Replace(sItemCodeDesc, """", """""") & """)"
oScript.Execute "Print 'Image'(""sItemCodeDescText""),sItemCodeDescText$"
End If
End If
End If
End If------------------------------
David Speck II
Tennessee Software Solutions
------------------------------
Original Message:
Sent: 08-24-2019 03:18
From: David Speck II
Subject: Display Value on Panel
For additional coverage of various methods, Alnoor had a good idea in this post.
https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-personalization-customization-and-productivity-tools/110657/dynamic-programatically-set-values-in-customizer-text-object
I also go over several methods in two answers in this post.
https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-personalization-customization-and-productivity-tools/108095/display-a-calculated-value-not-a-udf-on-a-customized-window/347939#347939
------------------------------
David Speck II
Tennessee Software Solutions
------------------------------
Original Message:
Sent: 08-23-2019 16:32
From: David Speck II
Subject: Display Value on Panel
Glad it worked for you.
In previous versions, i think maybe 2016-, the methods mentioned before worked but something seemed to have changed with the order in which the table post read events were firing and when values were being exploded from the IOList into the various controls on a given panel and i believe this is what causes the value to display briefly only to be overwritten again by whatever value was in IOList for the particular column.
So using the IO object's CMD_STR$ variable makes sure the command is processed afterwards.
I think at one point, i was using perform logic to use provideX code to add my own multi-line control to a panel either over top of a placeholder UDF added so i could reference it's position or hardcoding the position and then used a post read to maintain the value and since it wasn't part of the IOList tracked by the _svc or _bus object i didn't have to worry about it trigger a save prompt or being overwritten by the IOList. This method required more lines of code and was more of hassle to repeat for more than one piece of info that would you wanted to display.
------------------------------
David Speck II
Tennessee Software Solutions
Original Message:
Sent: 08-23-2019 16:20
From: Eric Lunceford
Subject: Display Value on Panel
You da man, David!
Works in 2019.1 as well.
------------------------------
Eric Lunceford
First Mate Business Solutions
Oklahoma City, OK
877-880-8960
https://www.firstmatellc.com/
Original Message:
Sent: 08-23-2019 00:12
From: David Speck II
Subject: Display Value on Panel
Alright, got a solution for this that appears reliable even on v2018.
Use Customizer to modify the panel where you need the value displayed.
Click the Add Field button and then click somewhere on the panel to trigger the udf selection prompt.
Click Show All.
Locate a field that says "Display-Only". If you can't find any in the "MAIN" folder (usually the key field is available for this purpose if you haven't put it elsewhere), expand the next folder in the list.
Add the first field and take note of the field name. It should start with "ALB_MAIN_".
Add the following code to the post load event for the panel where the udf was added and the tables post read event. Make sure to replace the field name and variables used in your implemention of this code. The important piece that must remain the same is the first argument of "SetVar". The field name following the "X" must match the udf name that you added to the panel.
sItemCodeDesc = "" : oBusObj.GetValue "ItemCodeDesc$", sItemCodeDesc
If oScript.UIObj > 0 Then oSession.AsObject(oScript.UIObj).SetVar "CMD_STR$", "X ALB_Main_ItemCode$=""" & Replace(sItemCodeDesc, """", """""") & """"
The first line of the code is not important, it just happens to be the piece of data that i wanted to set into this field added to the panel, you can replace the first line with whatever logic it takes to get the value that you want to set into the field added to the panel. Just make sure to reference the correct variable name in the second line.
The second line of code checks to see if the UI is present for this task, this is important in the post read event. It then uses the UIObj's SetVar method which is similar to the oBusObj's SetValue. The variable that we are setting is the CMD_STR$ variable that is local to the UI object and when it has valid providex code, it will be evaluated and executed depending on the very first character placed in the variable, in this case, we are setting the first character to "X" which tells the UI object to "EXECUTE" the rest of the string. The rest of the string is assigning whatever value you want to write to the field added to the panel to the variable for that control which is local to the UI object. In this case, the variable for the display only udf that i added is ALB_Main_ItemCode$, make sure to replace this with the correct field name displayed in Customizer's status bar. Also, double quotes in the value you want to assign have to be escaped before assigning it. This is what the [Replace(sItemCodeDesc, """", """""")] code is doing. Again, just replace the sItemCodeDesc variable with whatever variable name you decide to use.
Hope this helps.
EDIT:
The reason for using the Display-Only fields is because they are automatically excluded from the record validation routine that checks for fields that have changed, making them ideal for this purpose since they won't trigger the prompt to save.
------------------------------
David Speck II
Tennessee Software Solutions
Original Message:
Sent: 08-22-2019 15:10
From: Kevin Moyes
Subject: Display Value on Panel
How do you force a UI event?
------------------------------
Kevin Moyes
Technical Systems Analyst
Munjal White Consulting Co.
Toronto ON
Original Message:
Sent: 08-22-2019 15:05
From: David Speck II
Subject: Display Value on Panel
I didn't think about this before but if you use the calculated text and in a post read, force a post load of the panel, this should in theory redraw the text.
------------------------------
David Speck II
Tennessee Software Solutions
Original Message:
Sent: 08-22-2019 14:27
From: Eric Lunceford
Subject: Display Value on Panel
I ended up using the button method and making the event script also work tied to the button so if they are scrolling and don't see the value, they can click the button and it calculates and displays on the panel.
David, when I tried your method, the value wouldn't display:
@David Speck II mentioned in an old Sage City post to use UDF set as borderless and locked. While this method does avoid the save prompt, it also makes the value invisible. (You can see the value flash in the location it is placed, but then it hides.)
I really do wonder why Sage is unable to expose a Text property for a text control. There must be a super technical reason.....
------------------------------
Eric Lunceford
First Mate Business Solutions
Oklahoma City, OK
877-880-8960
https://www.firstmatellc.com/
Original Message:
Sent: 08-22-2019 00:19
From: David Speck II
Subject: Display Value on Panel
The trick with the ="calculate text here" in the text is really only useful on panels that are launched from an existing record, like a dialog panel as the formula is evaluated when the text is drawn which happens during the panel post load event.
If you need to update a value during the reading of records like you said, you can either use a UDF as a placeholder and set it to borderless and locked on the panel but you need a script on the post read event to set it's value like this.
Replace the contents in the bracket with the appropriate values.
If oScript.UIObj > 0 Then oSession.AsObject(oScript.UIObj).SetControlProperty [UDF_Name], "Value$", [value you want displayed]
------------------------------
David Speck II
Tennessee Software Solutions
Original Message:
Sent: 08-21-2019 14:05
From: Eric Lunceford
Subject: Display Value on Panel
Thank you, Kevin (and David).
That's a nice trick.
Unfortunately, this produces even more random results.
Scrolling through records shows 0 for several records, then suddenly a correct value, which now sticks until another one calculates. Scrolling back sometimes triggers a correct calc, which then sticks for a number of records going backwards.
Selecting from ALE does the same thing.
------------------------------
Eric Lunceford
First Mate Business Solutions
Oklahoma City, OK
877-880-8960
https://www.firstmatellc.com/
Original Message:
Sent: 08-21-2019 12:40
From: Kevin Moyes
Subject: Display Value on Panel
I've attached a copy of @David Speck II's instructions to do this...
------------------------------
Kevin Moyes
Technical Systems Analyst
Munjal White Consulting Co.
Toronto ON