Expand my Community achievements bar.

Listeners not working for dialog used in Dialog participant step in workflow.

Avatar

Level 3

Hi,

We have a requirement, in a workflow, having a dialog participant step, the custom dialog contains a datepicker field on which we need to set a future date based on some condition.

For this, I created a clientlib with category as cq.authoring.dialog, and in the js file, have written the logic for setting the value, but this does not work, if I click complete on the particular dialog participant step when I am executing the workflow on the page.

If the use the same dialog, inside a component and drag drop the component on a page, it works fine. My date is set to the future date.

Can anyone help on how to use listeners for a dialog used in a dialog participant step ?

We are using AEM 6.4.

Thanks in advance,

Ankush Dhingra

7 Replies

Avatar

Level 10

Please show your code you are using for this use case - it will help the community try and suggest fixes.

Avatar

Level 10

Also - if you want to get a value (ie - a date value)  from a dialog in a workflow - you should use Java in a custom step to read it.

Avatar

Level 3

Hi smacdonald2008

clientlib category - cq.authoring.dialog

code of listener.js

(function($, $document) {

    "use strict";

    $document.on("dialog-ready", function() {

(function($, $document) {

    "use strict";

    $document.on("dialog-ready", function() {

     

        var d = new Date();

        document.querySelector('coral-datepicker[name="./expirationDate"]').setAttribute("value", d.getFullYear() + ", " + (d.getMonth() + 1) + ", " + d.getDate());

    });

})($, $(document));

    });

})($, $(document));

​Dialog.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"

    jcr:primaryType="nt:unstructured"

    jcr:title="Set Expiration Date"

    sling:resourceType="cq/gui/components/authoring/dialog">

    <content

        jcr:primaryType="nt:unstructured"

        sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">

        <items jcr:primaryType="nt:unstructured">

            <column

                jcr:primaryType="nt:unstructured"

                sling:resourceType="granite/ui/components/coral/foundation/container">

                <items jcr:primaryType="nt:unstructured">

                    <expirationdate

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"

                        displayedFormat="MMMM DD, YYYY"

                        fieldLabel="Set Expiration Date"

                        name="./expirationDate"

                        type="date"

                        validation="hello"

                        value="today"/>

                </items>

            </column>

        </items>

    </content>

</jcr:root>

​Workflow model

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"

    jcr:primaryType="cq:Page">

    <jcr:content

        cq:designPath="/libs/settings/wcm/designs/default"

        cq:lastModified="{Date}2018-10-15T15:19:12.002+05:30"

        cq:lastModifiedBy="admin"

        cq:template="/libs/cq/workflow/templates/model"

        jcr:primaryType="cq:PageContent"

        jcr:title="Approval Content Model"

        sling:resourceType="cq/workflow/components/pages/model"

        workflowStages="[Content Creation,Approval,Publish]">

        <flow

            jcr:primaryType="nt:unstructured"

            sling:resourceType="foundation/components/parsys">

            <dynamic_participant

                jcr:created="{Date}2018-10-11T13:02:17.541+05:30"

                jcr:createdBy="admin"

                jcr:description="Author to validate the content expiration date."

                jcr:lastModified="{Date}2018-10-15T15:19:11.986+05:30"

                jcr:lastModifiedBy="admin"

                jcr:primaryType="nt:unstructured"

                jcr:title="Validate Content Expiration Date"

                sling:resourceType="cq/workflow/components/model/dynamic_participant">

                <metaData

                    jcr:primaryType="nt:unstructured"

                    DIALOG_PATH="/apps/myproject/components/workflowcomponents/setexpiration/cq:dialog"

                    DYNAMIC_PARTICIPANT="/libs/workflow/scripts/initiator-participant-chooser.ecma"

                    workflowStage="Content Creation"/>

            </dynamic_participant>

        </flow>

    </jcr:content>

</jcr:root>

​Steps to reproduce issue:

1. Start the workflow on a page.

2. On the Validate Content Expiration Date ​step, when we click on complete, in the dialog that opens, the js should execute and set the date in the Set Expiration Date field of the diaog.

3. This is not working.

Please let me know if any other details are needed.

Thanks in advance.

Avatar

Level 10

Are you sure you JS is loading. Try writing a console message to see if this code is executed

Avatar

Level 3

Hi smacdonald2008,

No, the js is not loading but it should have ideally loaded if we are using the cq.authoring.dialog clientlib category. I was going through the code in /libs and saw that the dialog that comes when Complete is selected in a workflow step, is created by a js file and is not a simple touch ui dialog.

So, I need to understand that how can we [put listeners on these dialog fields since it is created inside a js? Am even not sure if even after loading it would listen to the dialog-ready event.

Thanks in advance,

Ankush Dhingra

Avatar

Level 10

that is what i suspected - for some reason this is blocked in a workflow. I will look into this.

Avatar

Level 3

Hello All,

Even I am facing similar kind of issue in my workflow dynamic participant step. I have a dialog where it has a drop down values. Author needs to select at least one form the drop-down values(I need it as required field). But I am not able to achieve it either by giving the field as required or by using "js".

Right now even without selecting at least one from drop-down when they click on ok the dialog is getting closed and  going to next step. can anyone help me out on this?