Expression for checking if any sub-list entries have been made on the form - Needing to start a specific workflow if new items have been added to the sublist on my form
Original Post by Sandy (Imported from Ardevia Forum)
Hi,
Hoping someone can help with this....
Can I please have some code that compares the number of items and the values in those items when I came to the form and compare it with the number of items and values in those items at the time I click on the Form Submit button.
I have 2 sublist on my form, the first one is called top-ups and has two columns Description and Amount, the second is called transactions and has 3 columns Supplier, Date, Amount.
What I need to do is determine whether anything in these two sublists has changed since coming to this page so that I can do nothing if there are no changes, can submit workflow 1 if top-ups only have been changed/added, can submit workflow 2 if transactions only have been changed/added or submit workflow 3 if both top-ups and transactions have been changed/added.
I only really need to check the Amount columns to see if anything has been changed in an existing row.
Thanks in Advance
Sandy
-
Original Post by Markiyan (Imported from Ardevia Forum)
Hi Sandy
For doing this you can add the script which will be execuded when the form is loaded and the submit button is pressed. And afterwards you will be able to compare the retrieved values.
To get the sublist items count you can use the following:
Code:
var webpartId = "YourSubListWebPartId"; var webpartSelector = "[ard-webpart-id=" + webpartId + "]"; var gridController = jQuery(webpartSelector).data('Controller'); var grid = gridController.InstanseData; var itemsCount = grid.GetAllRecordIds().length;You should also change placeholder "YourSubListWebPartId" to your sublist Id.
To find this Id open developer tools in your browser (press F12 key). Select sublist and find a ard-webpart-id attribute on the parent element.0 -
Original Post by Sandy (Imported from Ardevia Forum)
Hi Markiyan,
What code do I need to use to compare the two values? I am wanting to compare them on the Submit button so that I can determine whether I need to start a workflow or not.
I have the code above with my webpart id on the form load action where the var = beforeTransCount and the same code on the submit action where the var = afterTransCount.
KR
Sandy0 -
Original Post by iryna (Imported from Ardevia Forum)
Hi,
you should have your variables declared using "window":
window["beforeTransCount1"];
window["afterTransCount1"];
window["beforeTransCount2"];
window["afterTransCount2"]Afterwards they can be used in any other action.
So, the actions on your "Save" button will look like this:
And the condition of your "Start workflow 1" action will have the following function code:
Code:
return window["beforeTransCount1"] == window["afterTransCount1"] && window["beforeTransCount2"] == window["afterTransCount2"];
0
Please sign in to leave a comment.

Comments
3 comments