How to add list collector to the form

Sweety11
Kilo Contributor

Hello

Can anyone explain me, ow to add a list collector to a form

Thanks in advance

16 REPLIES 16

Anshu_Anand_
Kilo Sage
Kilo Sage
 

I tried and finally came up with a solution:-

1. Created 2 fields Ritm lists and Bundle

find_real_file.png

 

2. Now since the bundle ID and RITM list is mapped, in another Ritm, if you try same RITM list bundle,

it will give the bundle number with green color means it exists else throw red color with new bundle ID mapped .

Done via onChange client script+script include

 

find_real_file.png

 

3. If bundle does not exits, then generated a new bundle ID with RED color showing it not exists

find_real_file.png

 

 

Client script on change of RITM list:-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
	g_form.clearValue('u_bundle');
	var lists = ""+ g_form.getValue('u_ritm');	
	var ga = new GlideAjax("getBundle");
	ga.addParam('sysparm_name','getBund');
	ga.addParam('sysparam_ritmList',lists);
	ga.getXML(getBund);
	function getBund(response) 
	{
        var answer = response.responseXML.documentElement.getAttribute("answer");
		var sp = [];
		sp = answer.split(",");
		
		g_form.setValue('u_bundle',sp[0]);
		var element = g_form.getElement('u_bundle');
		element.style.backgroundColor = sp[1];
	}			
   
}

find_real_file.png

 

Script include

var getBundle = Class.create();
getBundle.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	getBund: function(){	
		var bund = ""+this.getParameter("sysparam_ritmList");
		var bundle="";
		var array1=[];
		var array2=[];
		var gr = new GlideRecord("sc_req_item");
		gr.addEncodedQuery('u_ritmIN'+bund);
		gr.query();
		if(gr.next())
			{
				array1 = gr.u_ritm.split(",");
				array2 = bund.split(",");
				var array2Sorted = array2.slice().sort();
var rs = array1.length === array2.length && array1.slice().sort().every(function(value, index) {
    return value === array2Sorted[index];
});
				if(rs == true)
					{
					bundle = gr.u_bundle+","+"green";
					}
				else
					{
					bundle = "BUN"+Math.floor((Math.random() * 1000000) + 1)+","+"red";	
					}
			}
		if(bundle == '')
			{
				bundle = "BUN"+Math.floor((Math.random() * 1000000) + 1)+","+"red";
			}
		return bundle;
	}
});

find_real_file.png

 

If its helpful,please mark answer as correct

Regards,
Anshu

Thank you so much Anshu, for the clear explanation. It helps alot

If I want to hide the RITM's which are already bundled, how can I achieve this requirement using reference qualifier. and I want to create the bundle field as number type which will be generate automatically.

Thank you

where you want RITM to be hidden?

list collector of RITM ?

 

Regards,
Anshu

Yes, in list collector RITM. If I have selected the bundle of ritm's I don't want to display them in the list collector