power scripts/SIL scripts
Asked by Ashima Bhatia:

hi team,

I am passing below SIL script code in my workflow validator on In progress transition. It doesn't work. When I click on status button, the transition doesn't execute.

PFB problem statement.

When I check whether the Jira system field, due date is null in my SIL script, I get check error, and I am not able to display that error on my edit screen.

Also, If I add same for any other custom field, the transition doesn't get executed. I am neither able to proceed on next screen nor the error message is displayed on screen.

**code:**

errorMsg="Kindly set due date"

if(isNull(duedate) \|\| isNull(customfield_12345)

{

return false, "error",errorMsg;

}

**Check error:**

Undefined variable 'duedate'. Please define it prior to usage.

Since, duedate is system field, how do we declare it? Is the syntax valid to check if duedate field in null? If I remove due date check, and just keep my custom field null check, then I am not able to execute transition. As mentioned above, next screen doesn't show up.

Thanks

Ashima Bhatia


Answers:
author: Anna Hryhoruk _Appfire_
body: Hello [@Ashima Bhatia](/t5/user/viewprofilepage/user-id/5010928) ,

So, in your transition, you have a screen, and the due date field is present in that screen. Am I correct? In that case, if you want to check field value from transition screen you need to use [hasInput](https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15485945/hasInput). So, your validator should be like this:

```
string errorMsg="Kindly set due date";
if(!hasInput("dueDate")) {
  return false, errorMsg;
}
```

To properly refer due date in SIL you need to use name "dueDate".  

Please visit this page for more examples and a detailed explanation [Writing Conditions Validators and Post Functions](https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15487273/Writing+Conditions+Validators+and+Post+Functions)   

If my answer was helpful, please do not forget to accept it :)   

Best regards,  
Anna

comments: author: Ashima Bhatia
body: Thanks for the response Anna.

I tried this approach but still the same issue persists. I am not able to proceed with my transition.

Due date field that I am using is a system field. Any limitation because of incorrect syntax for system fields?

I tried with estimated start date and estimated end date(which are custom fields), by using !hasInput syntax, but same issue persists.

Is it any limitation of power scripts?

Because when I add required field validator of script runner, instead of SIL/power scripts, I am able to execute my transition.


author: Anna Hryhoruk _Appfire_
body: No, there is no limitation. Yes, due date is a system field so please ensure you used exactly the same naming in the script "dueDate" as I mentioned above. Also, ensure that you saved the script and published the workflow version.  
Can you share the screenshot of the transition screen and the script you are currently using?


author: Ashima Bhatia
body: Hi Anna,

Sharing the SIL script, which is added as a validator for In Progress transition of my workflow.

Also, added screen shot of transition screen.![in progress screen.png](https://community.atlassian.com/t5/image/serverpage/image-id/334176i00EC00B9C11DA83E/image-dimensions/332x238?v=v2 "in progress screen.png")

string errorMsg = "'Due date', 'Estimated Start Date' and 'Estimated End Date' must be set first to start the progress on this Migration task!";  
if ((project == "DACL" \|\| project == "ADDEMERGE") \&\& type == "Migration") {  
if ( !hasInput("dueDate") \|\| !hasInput(customfield_13606) \|\| !hasInput(customfield_13607)) {  
return false, errorMsg;  
}  
else  
{  
return true;  
}

Thanks

Ashima Bhatia


Tags: jira-server

server