- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 08:11 AM
I modified the Planning UI Action so that it will check to see if a specific task has been closed. If the record is still active then it will display an alert/error, otherwise it will just update the record.
I'm aware that the final if is still using current and it's on the client side but right now the button does nothing.
Weirdly, if I add an alert before the first var declaration it will display after updating the UI Action.
// get sys_id for current project record
var prjRec = g_form.getValue('number');
// declare gliderecord and query against related project and stage gate requirements
var prjGlid = new GlideRecord('pm_project_task');
prjGlid.initialize();
prjGlid.addQuery('top_task.number', prjRec);
prjGlid.addEncodedQuery('short_description=Planning Phase Completion^key_milestone=true');
prjGlid.query();
var row = prjGlid.getRowCount();
var checkCount = 0;
while(prjGlid.next() && row == 1)
{
alert('in loop');
if(prjGlid.active == true)
{
alert('Invalid Update - Planning Stage Gate is not complete');
checkCount++;
}
}
if(checkCount == 0)
{
alert('in final if');
current.phase = 'planning'; // ori
current.state = '2'; // ori
current.update(); // ori
action.setRedirectURL(current); // ori
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 08:25 AM - edited 07-02-2024 08:28 AM
Since you have the Client box checked on the record for this UI action, you need to add your Function that is declared from your Script into the Onclick field to get it to do anything when clicked. You'll also need to do a lot of changes to your code to run Client and Server Side script in the same code.
Here are some examples from the docs page on how you can do that

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 08:25 AM - edited 07-02-2024 08:28 AM
Since you have the Client box checked on the record for this UI action, you need to add your Function that is declared from your Script into the Onclick field to get it to do anything when clicked. You'll also need to do a lot of changes to your code to run Client and Server Side script in the same code.
Here are some examples from the docs page on how you can do that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 10:09 AM
Hey @Zach Koch - this looks like it should suit my needs. I'll modify my code and get back with results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 12:01 PM
Hey @Zach Koch,
I ended up doing something different, using a GlideAjax call to handle the server-side scripting and moved everything into functions. The Onclick was required though so I appreciate seeing that error. Accepting as solution!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 12:02 PM
Great! I'm glad you were able to come up with a solution.