create incident record producer issue in Service portal

nameisnani
Mega Sage

Hi Team , 

 

can any one please help me here .

 

When we are creating incident from Platform . 

 

If we select category > Application then Department , Application name and Issue type will appears, for more info please refer the screenshot below . 

 

nameisnani_0-1714991529196.png

 

Here Application Name is reference field , which refers to 'cmdb_ci_service_list' table , Please refer the screenshot below .

 

nameisnani_1-1714991925800.png

 

If i select Application Name with some value 

 

Exmaple : - Application name > Firewall Production , Then automatically associated assignment group populated ( Tcs Network sup).

 

Show in screenshot .

nameisnani_2-1714992033573.png

 

Platform side everything is working fine , When comes to Serivceportal side .

 

nameisnani_3-1714992245040.png

 

I have selected ' Application name has ' Firewall Production' .

nameisnani_4-1714992275029.png

 

And i submitted the incident.

 

If u noticed here , Assignment group is blank ,  I don't know what was the issue here .

nameisnani_5-1714992418257.png

 

Scripts we have for this 

nameisnani_6-1714992493261.png

u_taskAjax = Class.create();
u_taskAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	getassignmentgroup: function() {
		var trgt = this.getParameter('sysparm_target');
		var serviceGR = new GlideRecord('cmdb_ci_service');
		serviceGR.addQuery('sys_id', trgt);
		serviceGR.query();
		if (serviceGR.next()) {
			return serviceGR.support_group;
			}
	},
type: 'u_taskAjax'
});

 

nameisnani_7-1714992527123.png

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //To auto populate assignment group based on services.
	var business_service = newValue;
	var businessServiceAjax = new GlideAjax('u_taskAjax');
	businessServiceAjax.addParam('sysparm_name', 'getassignmentgroup');
	businessServiceAjax.addParam('sysparm_target', business_service);
	// submit request to server, call ajaxResponse function with server response
	businessServiceAjax.getXML(subAjaxResponse);   
}
	
	function subAjaxResponse (response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		g_form.setValue('assignment_group', answer);
        g_form.update();
	} 

 

 

nameisnani_8-1714992603922.png

 

var isMobile = GlideMobileExtensions.getDeviceType() == 'm';
var link = isMobile ? '#/!list/incident/q:active=true%5Ecaller_id=javascript:gs.user_id()%5EEQ' : 'home.do';

var linkLbl = isMobile ? "List" : "Homepage";
var br = '<br/>';
var linkURL = '<a href="' + link + '">' + gs.getMessage(linkLbl) + '</a>';
var msgArgs = [br, linkURL];

var info = gs.getMessage("This incident was opened on your behalf{0}. The IT department will contact you if they need any further information{0}You can track status from this {1} {0}", msgArgs);

gs.addInfoMessage(info);
var caller = gs.getUserID();
var parent_table = RP.getParameterValue('sysparm_parent_table');
if (JSUtil.notNil(parent_table)) {
    var parent_map = new GlideRecord('request_parent_mapping');
    parent_map.addQuery('parent_table', parent_table);
    parent_map.query();
    if (parent_map.next())
        var requested_for_field = parent_map.getValue('requested_for_field');
    var parentGR = new GlideRecord(parent_table);
    parentGR.addQuery('sys_id', RP.getParameterValue('sysparm_parent_sys_id'));
    parentGR.query();
    if (parentGR.next())
        caller = parentGR.getValue(requested_for_field);
}
current.contact_type = 'self-service';
current.caller_id = caller;

var prodCommentStr = producer.comments + "";
/*if (prodCommentStr.length > 80)
current.short_description = prodCommentStr.substring(0, 80);
else
current.short_description = prodCommentStr;
    */
current.description = prodCommentStr;

var incRPUtil = new LinkRecordProducerToIncident();
incRPUtil.linkRecordProducerToParentIncident(RP.getParameterValue('sysparm_parent_sys_id'), current);

 

 

So , our issue when ever from ServicePortal side , 

 

Based on Application Name field Value , Assignement group has to be pouplate .

 

Please review our script , what steps need to do .

 

can anyone please help me here with steps to achieve this issue .

 

Thanks in advnance

6 REPLIES 6

Mark Manders
Mega Patron

Why do it from the portal, why not create assignment rules to update the record on creation so it ends with the correct group? You can get rid of the entire scripting to get the assignment group.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

nameisnani
Mega Sage

Hi @Mark Manders 

 

Application Name field is a reference field , we have 2lac above CI's , we can't create those many assignement rules right , 

 

How do you mean 'so many assignment rules'? It's just one: set assignment group to support group of CI (or whatever relation there is). 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

AnimeshP_96
Tera Guru

@nameisnani Assuming its a record producer and it create a incident record in backend view

in record producer script 

use below code :

 

if(producer.variable_name=="sysid of the applicationname from variable")

{

current.assignment_group=" ";//set the group you want to set 

}

 

easy as you like.... let me know if this works


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh