How to get list collector values as string

Samiksha2
Mega Sage

Hi All,

I am working in JIRA-Request Integration.
I have to push list collector values to JIRA. 

All other values to syncing to JIRA except this one.

Here is my code:

var fieldsArr = [];
var ritmGr = new GlideRecord('sc_req_item');
    ritmGr.addEncodedQuery('cat_item=13cee83e9386f55034dbbb2c5cba^request='+ fd_data.trigger.current.sys_id);
    ritmGr.query();
    if(ritmGr.next()) {
        var short_des = ritmGr.short_decription;
        var csm = ritmGr.variables.csm;
        var prod = ritmGr.variables.csm_product.name;
        if(prod=="MCB"){
            var list = csm_specify.getDisplayValue();
	    var array = list.split(',');
	    for (var i=0; i < array.length; i++) {
	    var subProd= array[i];
	   }
	else{
	    var list = csm_specify_next.getDisplayValue();
	    var array = list.split(',');
	    for (var i=0; i < array.length; i++) {
	    var subProd= array[i];
	}
        }
    }

//SN Variables
fieldsArr.push('customfield_109=' + csm);
// Product
fieldsArr.push('customfield_103=' + prod);
//Subproduct
fieldsArr.push('customfield_106=' + subProd)
return fieldsArr.join('^');

Product, CSM is syncing. when i am selecting only one option in the list collector then value is populating in JIRA but more than one its giving error.

 

Please help here.

 

Thanks,

Sam

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Unfortunately your post and code do not make your requirement clear, and I think you have syntax issues

  • Missing a } possibly related to if(prod=="MCB"){
  • The reference 'csm_specify' does not appear to exist, at least not in the supplied code?
  • You have a variable subProd which is created within a for loop and then assigned the content of array[i], but for each 'loop' the variable would be recreated and repopulated with the value relating to i,
    then destroyed when the loop ends which would mean that subProd doesn't exist when you try push it into fieldsArr[].

 

Can you clarify your issue\configuration\requirements, so that the community can better understand the problem that you are facing?

Samiksha2
Mega Sage

Hi @Tony Chatfield1 ,

Thank you for the reply. Issue got resolved by the below code.

 

var subProd= ritmGr.variables.csm_specify.getDisplayValue().split(', ');

 

 

Thanks,

Sam