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:57 AM
The code was not meant to run exactly as I typed it. I was guessing at the value for "work in progress" (2). You need to adjust the script to fit your situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 08:08 AM
Whatever the I written that works fine from changing the state Scoping to Awaiting approval. But the same code written for changing "awaiting approval " to "work in progress" it cant change directly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 08:06 AM
You need an after business rule on rm_feature and put this script in there.
When after insert and update
conditions: state changes to awaiting approval
Script:
var gr= new GlideRecord('rm_feature');
gr.addQuery('parent',current.getValue('parent'));
gr.addQuery('sys_id',current.getValue('sys_id'));
gr.addQuery('state','!=',2);
gr.query();
while(!gr.next()){
var rel= new GlideRecord('rm_release');
rel.get(current.getValue('parent'));
rel,state=2;
rel.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 08:17 AM
Thanks for reply. I create a workflow for changing the states in feature.based on states of all feature records i want to change the state of release. For that I write business rules in rm_release table.So the code i written for changing the state "scoping" to "awaiting approval" works fine. but same code with changing states written for "awaiting to approval" to "work in progress" the state is changed only update the field in release form but it can't changed directly to "work in progress"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 08:09 AM
You need a business rule on rm_feature table to change your release state automatically when all the features go to awaiting approval