Changing state to working in progress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 07:04 AM
in release i written the code for changing awaiting approval to work in progress when all feature records are changed to work in progress
the code is working but it changes the state when update the release record field. how can it changed directly with out updating release record
field.
var gr = new GlideRecord("rm_feature");
gr.addQuery("parent",current.sys_id);
gr.query();
var count=0;
var len =gr.getRowCount();
gs.log(len);
while(gr.next())
{
gs.log('hi');
if(gr.state == '2'||gr.state == '8'||gr.state == '10'||gr.state == '3')
{
count++;
if( len == count)
{
gs.log(count);
current.state = '2';
current.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 07:13 AM
Hi Sandeep,
Create an AFTER business rule on the rm_feature table. You are close... If you want to update the state of the rm_release record when all feature records are state 2 (work in progress) it would look something like this:
Name: Update release record to WIP
Table: rm_feature
When: AFTER
Advanced: true
Insert: true
Update: true
Condition: current.state.changes()
Script:
/// Standard executeRuleTemplate function declaration
var parentID = current.getValue('parent');
// Check there are any records NOT at state 2 (WIP)
var f = new GlideRecord('rm_feature');
f.addQuery('state', '!=', 2);
f.addQuery('parent', parentID);
f.query();
// If there are no fields NOT at state 2, then they are all at state 2
if (f.getRowCount() == 0) {
var r = new GlideRecord('rm_release');
if (r.get(parentID)) {
r.state =2;
r.update();
}
} else {
gs.log('There are still some releases that are not at WIP for this parent release.');
}
PLEASE NOTE THIS CODE IS UNTESTED AND MAY REQUIRE MODIFICATIONS TO WORK> REVIEW CAREFULLY BEFORE COPYING/PASTING AND PRAYING!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 07:27 AM
Thank for reply I tried but again same situation. It can't change to working in progress directly.
Thanks &Regards
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 07:39 AM
Can you explain what that means? I'm not clear.
It can't change to working in progress directly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 07:54 AM
I tried the code that you have send. but it is not changing to working in progress directly .
Thanks & Regards
J.Sandeep