- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 08:41 AM
Hi All,
Hopefully someone can help with the following. it sounds simple enough, but I can't get what I want to do to work.
What I need to happen is for a variable on a request task form to become mandatory on or before the 'Close Task' action. I have explored this via UI Policy and got it to work for it to be mandatory. However, the issue I have with that method is the task will need some work completing before variable information is acquired and you cannot save it as the field has already become mandatory.
The method I am now exploring is the onSubmit client script, but I am open to other options...
function onSubmit() {
var action = g_form.getActionName();
if (action != 'close_sc_task')
return;
var state = '3'; // Closed Complete State
if (action == 'close_sc_task');
g_form.setMandatory('business_email', true); // business email is the variable that need to become mandatory
}
What I have seen with the above script is that the business email variable flashes briefly with the mandatory asterisk, but the task closes anyway. Any help would be appreciated.
Many Thanks...
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 01:09 PM
I think I used the wrong syntax for the business rule. After Helsinki, they changed the syntax and no longer use onBefore() onAfter() methods. See if you can use this in your Set g_scratchpad for sc_task business rule:
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.wf_activity = current.wf_activity.getDisplayValue();
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:16 AM
Did you create the onDisplay Business Rule? If you did, you should be able to determine what the Workflow Activity name is through the JavaScript Editor [Control][Shift][j]. Then run the following to get what the activity name is when you are in that task:
alert(s_scratchpad.wf_activity);
Let us know what the Workflow Activity is so we can adjust the code accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:25 AM
Yes first ths I did was to create the display business rule.
The task in the workflow is called "Fulfill_AD_Task"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:35 AM
Based upon the thread as well as what you indicated, the Close Task UI Action should be the following:
function closeTaskCheck() {
if (g_scratchpad.wf_activity == 'Fulfill_AD_Task') {
g_form.setMandatory('variables.business_email', true);
}
gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
if (typeof window == 'undefined') serverCloseTask();
function serverCloseTask() {
current.state = 3;
current.update();
}
I am hoping that Fulfill_AD_Task is the actual name of the Workflow Activity. Is that what shows up when you view workflow from the Catalog Item? If it is, then it should work. If not, please give us a screen shot of your UI Action as well as your workflow highlighting which task this occurs with.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 07:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 07:48 AM
Send me an email (chris.johnson AT fruitionpartners.com) and let me know your availability. I would like to see what you have built so far and make sure that it is set up properly.