Recently a customer inquired about an interesting challenge. They wanted to control the value of a text field on their SOLIDWORKS PDM Data Card by using a “Checkbox” field. The idea was to have a checkbox to indicate whether or not the file required approval, this would control how the file moved through the Workflow. But they also wanted it to affect the value displayed in the “Approved By” and “Approved Date” fields.
This was a perfect place to use Input Formula Aliasing. Input Formulas can be added to any “Edit” field in a data card, but in addition to the list of Functions that can be found in the SOLIDWORKS PDM Card Editor interface for Input Formula, you can also create a list of aliases based on the value from another variable in the same card. Frequently this is used when the other variable is linked to “Combo box” field that relies on a list, but it can also be used when the other variable is linked to a “Check box” field.
Input Formula Aliasing uses the format: %VARIABLENAME(VALUE1=ALIAS1, VALUE2=ALIAS2)%
So in our case, the “VARIABLENAME” would be name of the variable that is linked to the “Checkbox” field. Checkboxes on the data card are binary, so a checked box will set a value of “1” to the variable, unchecked boxes set the value to 0.
Our goal is to have the “Edit” fields for “Approved By” and “Approved Date” to show “N/A” if the box is not checked and to show “PENDING” if the box is checked (once the file passes through the approval stage of the workflow the username of the approver and the date they performed the approval will be set by a Transition Action).
So the “VALUE1” we will use will be “1”, meaning the box is checked, and “ALIAS1” will be “PENDING”. The “VALUE2” will be “0”, for the unchecked box, and “ALIAS2” will be “N/A”
The formula will be: %Approve Required(1=PENDING, 0=N/A)%
This formula will be added to the Input formula control on both the “Approved By” and “Approved Date” fields.
Also, it’s important to remember that the Input formal will not trigger until the user either checks or unchecks the linked checkbox. So if they do nothing, the input formula will not be triggered, and so it won’t input a value to the “Edit” box. In this case, the default state for our “Approval Required” checkbox will be “Checked”, so we will enter a “Default value” of “PENDING” for box of both of the “Edit” fields.
The result will be that by default when a new file is created in the vault, the “Approved By” and “Approved Date” fields will show “PENDING” and the “Approval Required” check box will be checked. If the user unchecks the checkbox, then the values in the “Approved By” and “Approved Date” fields will change to “N/A”. If the user checks the box again, they will change back to “PENDING”
Want to do more with SOLIDWORKS PDM?
Our Certified SOLIDWORKS PDM Experts can help you to: