- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2018 02:20 AM
Hello,
I am trying to run this script on a business rule on the std_change_proposal table but nothing is being returned in the while loop.
(function executeRule(current, previous /*null when async*/) {
//u_m2m_std2chg
var chgs = [];
chgs = current.change_requests.toString();
chgs = chgs.split(',');
while(chgs.next()){
gs.info(chgs.getDisplayValue());
}
})(current, previous);
I am trying read from the list in Sample Change requests
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2018 05:20 AM
Hey,
Not sure if you are trying to get the Change numbers or Sys IDs of them. So,
If you need Sys_ids then, use below
(function executeRule(current, previous /*null when async*/) {
// no need of this. You may remove it. var chgs = [];
var chgs = current.change_requests.toString();
chgs = chgs.split(',');
var i=0;//Decalre a loop variable
while(i<chgs.next()){
gs.info(chgs[i]);//Print sys_id of the change
i++;
}
})(current, previous);
OR
if you need change numbers then, use the below
(function executeRule(current, previous /*null when async*/) {
// no need of this. You may remove it. var chgs = [];
var chgs = current.getDisplayValue("change_requests");//Update the code here
chgs = chgs.split(',');
var i=0;//Decalre a loop variable
while(i<chgs.next()){
gs.info(chgs[i]);//Prints Change numbers
i++;
}
})(current, previous);
Good Luck!
Mark this as Correct and useful if it was.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2018 02:53 AM
Hi
use below
var chgs = [];
chgs = current.change_requests.toString();
chgs = chgs.split(',');
for(var i=0;i<chgs.length;i++){
gs.info(chgs[i]);
}
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2018 05:20 AM
Hey,
Not sure if you are trying to get the Change numbers or Sys IDs of them. So,
If you need Sys_ids then, use below
(function executeRule(current, previous /*null when async*/) {
// no need of this. You may remove it. var chgs = [];
var chgs = current.change_requests.toString();
chgs = chgs.split(',');
var i=0;//Decalre a loop variable
while(i<chgs.next()){
gs.info(chgs[i]);//Print sys_id of the change
i++;
}
})(current, previous);
OR
if you need change numbers then, use the below
(function executeRule(current, previous /*null when async*/) {
// no need of this. You may remove it. var chgs = [];
var chgs = current.getDisplayValue("change_requests");//Update the code here
chgs = chgs.split(',');
var i=0;//Decalre a loop variable
while(i<chgs.next()){
gs.info(chgs[i]);//Prints Change numbers
i++;
}
})(current, previous);
Good Luck!
Mark this as Correct and useful if it was.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2018 07:01 AM
HI,
Use below Script:
(function executeRule(current, previous /*null when async*/) {
//u_m2m_std2chg
var chgs = [];
chgs = current.change_requests.getDisplayValue().toString(); // Hope change_request is a field name of the Sample Change Request.
chgs = chgs.split(',');
for(var i =0; i<chgs.length;i++)
{
gs.log(chgs[i]);
}
})(current, previous);
Thanks,
Ashutosh Munot