To Set the value from Business rule

Suvedha
Tera Expert

Hi all,

 

I have Multi row Variable set, those variables should be displayed in RITM's Description field.

I have done scripting for this in Business rule. While setting the value it is getting only first record, not all the values.

I am going somewhere wrong in loop i guess. Could any one guide me?

 

var mrvs = current.variables.madrid_hq_varibales;
 
 
var rowCount = mrvs.getRowCount();
gs.log(mrvs.getRowCount());
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
var app = row.description1;
    var app1 = row.quantity1;
    var app2 = row.refer;
var gr = new GlideRecord('u_madrid_hq_facilities');
gr.get('sys_id',app);
var res = gr.u_texto_breve_de_material; 
current.description = res;   // here it is setting the first record, not all the records
}
})(current, previous);
 
Thanks & regards,
Suvedha
2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, unfortunately your post does not make your configuration or requirement clear and you code appears to be incomplete? With your current code you appear to be setting the value of 'res' at every loop and so it will always be the value delivered by the last loop/row. But your post indicates the first row, can you confirm that the loop works as expected and you can see\log each row as you iterate through the rows?

 

Perhaps you could update this thread with clear details of your requirement and of your debugging. so that the forum can understand your intentions, and the issue that you have with your code.

 

Manmohan K
Tera Sage

Hi @Suvedha 

 

Check with below code.

var mrvs = current.variables.madrid_hq_varibales;
var desc='';

var rowCount = mrvs.getRowCount();
gs.log(mrvs.getRowCount());

for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
var app = row.description1;
    var app1 = row.quantity1;
    var app2 = row.refer;

var gr = new GlideRecord('u_madrid_hq_facilities');
gr.get('sys_id',app);
var res = gr.u_texto_breve_de_material; 
desc= desc+ res +', ';   // here it will add values of all mrvs rows
}

current.description= desc;