Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting value for "Workflow Current Node"

Irfan_Khan
Collaborator II

I am trying to get the value of advanced workflow field called "Workflow Current Node". This is a text field and locked as it is system field. It shows the name of your workflow node. The field is on layout and visible to users.

 

I tried with $CM but getting null value.

$CM.getFieldValue(16684)

 

If anyone has pulled the value from workflow current node field then please let me know.

1 ACCEPTED SOLUTION

Accepted Solutions

Irfan_Khan
Collaborator II

no problem. I found it.

 

var val = $("#master_DefaultContent_rts_s5444_f35435c").text();

View solution in original post

5 REPLIES 5

Irfan_Khan
Collaborator II

no problem. I found it.

 

var val = $("#master_DefaultContent_rts_s5444_f35435c").text();

Issue is that exact code is environment specific  It will not work for others as it is, but gives an idea.

Irfan_Khan
Collaborator II

Yes, totally agree with you. I should put a disclaimer that in order to find out the exact field in your environment you need to open browser debugger tool and search for the field value or field ID in jquery and you will find something similar and you can use it in above syntax to pull the value.

 

Thanks

Irfan,

Getting the field value of that workflow node field may not work with the $CM.getFieldValue in read mode.  But, I believe it will in edit mode.  *Don't ask me why.

 

However, you should always be able to get client id of the field whether you're in edit or read mode.

 

Side note - Since having multiple environments, I generally declare a variable.  I.e.

var CurrentNode_FieldID;

Then, when the script loads, based on the environment the code populates it with the field ID for the specific environment.  

 

Then, before I perform any functions, I make sure that the script can find that field.  If you don't, you may have issues later.  i.e. the javascript doesn't like searching for a field that doesn't exist.

It is a good idea to perform action based on environment. In our case we refresh our lower environments with a Production copy then we use a data masking script to wipe out any confidential data. So technically our field ids are same in all environments.

 

For workflow node I noticed that the it was working on 1st approval the on 2nd node it was returning blank, now I understand its not my code it works in edit mode. Thanks for sharing that with me.

 

I am currently working on a code to capture the Who clicked Approve/Reject buttons in advanced workflow and populate their name in a user group field. There are up to 3 approval stages for some of the lines of business like Audit and Compliance. I am using a text field to set the approval stage and based on the value populate the appropriate approver field when a user clicks. For example, if it is 1st level approval then populate Approver 1 field, 2nd approval then Approver 2, 3rd approval then Approver 3, if Rejected then send back to Approval 1 stage after capturing the user name.

 

So far the code is working using get value, set value and set text area functions. I just need to arrange the code and apply it to the whole workflow.