Differences

This shows you the differences between two versions of the page.

Link to this comparison view

control_-_using_a_checkbox_to_update_a_variablepropertybag [2019/01/30 09:22] (current)
Line 1: Line 1:
 +Variable Property Bags are a way to store values and text and then utilize that information later for any number of different reasons. This article will cover 1 specific case where a particular customer was interested in capturing some notes each time an employee edited an order, changed a specific quantity variable and clicked Add. Upon change of that quantity variable the user wanted a text entry written to a variable that would serve as an edit log for the line item.
 +
 +
 +
 +===== Concept =====
 +
 +
 +
 +To accomplish this "edit log" we'll create a couple variables and modify the pricing form to include them as a checkbox and a designer memo. 
 +
 +
 +
 +===== Cautions =====
 +
 +
 +
 +Warning: You will be changing your live system, it is recommended you make a backup before proceeding with any changes to minimize the impact should your changes result in an inadvertent issue arising. ​
 +
 +
 +
 +===== Steps =====
 +  - Create a Yes/No variable named AddToEditLog
 +  - Put this formula in the **Actions when value changes** box.
 +
 +
 +
 + <​code>​
 +// We create a local variable and set it equal the value of a property bag variable named "​Result" ​
 +declare CurrentValue := GETVARIABLEPROPERTYTEXT(EditLog,​ "​Result",​ ""​);​
 +// We create a second local variable and set it equal to the a custom string of the Employee Full Name 
 +// + the current date/time + some custom text + the value of the Rejected Qty variable. + the current value.
 +// This will allow us to create an ongoing list of entries in the log by appending the new value to the previous value. ​
 +declare NewValue :=  User.Employee.FullName +  " " + DISPLAYDATETIME( Today) + " Qty Rejected: " + ToString(RejectedQuantity) + " " + currentvalue;​
 +// After we have establish the new value we then update the property bag for the EditLog variable which will be responsible for displaying the actual logs in our memo description pricing form component.
 +SetVariableProperty(EditLog,​ "​Result",​ NewValue);
 +</​code>​
 +  - Create a Text variable named EditLog
 +  - Set the variable to use a Formula for it's default value then use the formula below.
 +
 +
 +
 + <​code>​
 +// We reference an invalid object reference to force Control to always recalculate/​refresh. ​
 +// Since property bags aren't monitored for changes by Control this is needed else the memo description ​
 +// pricing form component won't update on the screen during order entry.
 +User.Text;
 +// We then set the default value equal to the text that was inserted into the Result variable of the property bag. 
 +GETVARIABLEPROPERTYTEXT(EditLog,​ "​Result",​ "​(blank)"​);​
 +</​code>​
 +  - Add a memo to your pricing form and link it to the EditLog variable.
 +  - Add a checkbox to your pricing form and link it to the AddToEditLog. ​
 +  - Change the background color, caption, font, etc. to style the checkbox accordingly. If you want the checkbox to resemble a button, then you can place the checkbox on top of a panel and turn on the option to UseCustomGlyphs which will remove the checkbox itself.
 +  - Create a new order then toggle the checkbox on/off and you should have text populate the memo field you added to the pricing form.
 +
 +
 +
 +==Sample Pricing Form==
 +
 +
 +
 +In the screenshot example below I clicked the Add to Log button, then changed the rejected qty, click it again, then did that another time. 
 +
 +
 +
 +{{::​pricingform-checkbox_as_a_button.png?​nolink&​|}}
 +
 +
 +
 +===== Source =====
 +
 +
 +
 +Contributor:​ Brandon Readlinger, Cyrious
 +
 +
 +
 +Date: 1/28/2016
 +
 +
 +