Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Submit to Draft

Avatar

Former Community Member

Hi all,

Is it possible to find whether the form is submitted to workflow or draft, through javascript?

The form should act different if the form is submitted to draft.

Please help.

4 Replies

Avatar

Level 6

In my forms I do this I keep a field or XML tag open for this purpose. At the end of the workflow submission I send a specialized message from workflow to the submitted instance of the form as submit response. Once the user submits I wait for that response from the workflow server and then based on the response I set the dedicated field (you can name it Status or SubmitStatus) or the particular XML tag to the value (for example "SubmitSuccess"). And next time when the user opens this saved instance ( I manage the form appearance based on the set value in that field or XML tag) they see the form is locked and can not submit the same instance again.

Hope you got the idea now.

Good Luck,

Avatar

Former Community Member

Hi

Thanks for the reply.

Are you using AWS_STATUS field to store the workflow submission status? How do you get the response from the workflow server? Can you please explain in detail.

Thanks in advance.

Avatar

Level 6

What you are asking is entire concept….

            In my environment I design PDF and XDPs, I dedicate one particular hidden field some where on the form for storing "status". When loaded the form instance for the first time it will default to 0 or null. I will have a script on this field’s ‘docReady’ event based on the value it will determine the status of the form. So if any thing other than the default value 0 or null indicates the form is already submitted and then based on that logic I lock the form fields being edited or submitted again. Being this done I will have a regular submit button and on ‘click’ event I will run the code to submit the required values to LC Workflow server (of-course you can add all kind of validations before you submit on the same script) then wait for the server response. Based on the server response I will set the value of the hidden field to 1 or ‘Submitted’ so it will be different from the value when loaded. Now if the user save the form locally and try to open the same instance he/she already submitted the code in ‘docReady’ event reads the value in the hidden field and determines the stat of the form as already submitted rather than new. But when the user opens the template from it’s original location the same field is initialized with default value there buy the same code determines it to be new instance and have not submitted yet.

            Now on the Workflow side as you can set up input (required/optional) variables you can also specify output variables. In my workflows I always setup just one Output variable and make it as XML based. So I can send response back to the requesting form instance. Since it is XML output variable I specify some XSD and can have multiple XML tags then at the end of the process I manually set the values of those XML tags for Output variable. For example I name one of the tag as <processResult> and will set the value to be “Success” if the process reached that end action assuming process will fail if that end action is not reached.

Case1: Process is Successful: now since you set the process to set the value of the <processResult>Success</processResult> the result of the submit process that is received on the form side will be some XML with the value in the <processResult> tag as “Success” after comparing this value you will set the hidden field on the form to read a value 1 or “Submitted” and hide the submit button.

Case2: Process failed: Since the process failed before it reaches the last action in the workflow. Then process never sets the value of the <processResult> tag in the Output XML so the result that is captured in the form will never have the value “Success” in that particular tag there by determining the process in failed and the use a message box/alert to explain the user that submit is not successful and they may try again keeping the options open to submit again.

I did my best to explain. This could be still be confusing unless you try in real time. It took long time for me to come this approach in my environment. I can make some samples if you need additional help but I want you try first.

Good Luck,

Avatar

Former Community Member

Right now, we are using adobe workflow server fields for submitting the form to the workflow. so it will ensure that the form is submitted only once. It also displays an error in forms manager in case if the user tries to submit the form for the second time. So we are not manually taking care of submission as you specified.

I think my query was not very specific to my requirement. I apologize for that.

Actually my form acts different when the user places the form in "Drafts" folder. So my requirement is to check whether the form is submitted to draft or whether it is reinitiated.

Please help if you have any idea on this.