Skip to main content

Search

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

Comments

3 comments

  • ArdeviaForum

    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
  • ArdeviaForum

    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
    Sandy

    0
  • ArdeviaForum

    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:

     

    tg3dDLW.png

     

    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.