Create a Problem from Incident UI action issue copying INC assignment group

davematz
Giga Expert

I am unable to get my NOW Learning task to complete successfully.

I need to create a new problem from an incident with all necessary information.  The following fields should be copied from an incident when a new problem is created from an incident: Configuration item, Priority, Assignment group, Short Description, Description.

The OOTB has all configured except the assignment group.  I've tried modifying the Script for the Create Problem (incident table) UI Action.  I added a line:

prob.assignment_group == current.assignment_group; 

this gives me an error "Expected an assignment or function call and instead saw an expression.  I understand the error message, but don't know what I needed to do to get the correct answer to solving this task.

Please instruct me on what the correct answer is and why so I can understand and learn.

Thank you

15 REPLIES 15

Yes the NOW Learning simulator is on Madrid.

I do not understand your instructions...need more step by step on what to do.  I am trying to learn and right now don't understand all of this.

Hi,

 

First try to find property: com.snc.problem.create_from_incident.attributes in sys_properties table.

If the property is already present then see which fields are there in this property. If the property is absent then create this property and add the fields which you want to copy.

 

Why i am talking about this property is because this property is getting called from the scriptinclude named as: IncidentUtilsSNC.

 

This script include is called from UI Action.

 

Thanks,
Ashutosh Munot

This is what I have, but I still don't understand how to get the assignment group to to copy to Problem from Incident.

getProblemFromIncident: function(current) {
if(!current.isValidRecord())
return undefined;

var fieldsToBeCopiedFromIncident = [];
var prob = new GlideRecord("problem");

var record = new GlideRecord('sys_properties');
record.addQuery('name', 'com.snc.problem.create_from_incident.attributes');
record.query();

if(record.next())
fieldsToBeCopiedFromIncident = this.getCsvValue(record.value);

for(var i = 0; i < fieldsToBeCopiedFromIncident.length; i++) {
if(fieldsToBeCopiedFromIncident[i] === 'number' && prob.isValidField("first_reported_by_task"))
prob.first_reported_by_task = current.getUniqueValue();

else if (fieldsToBeCopiedFromIncident[i] === 'category') {
var elCategory = prob.getElement("category");
var choicesCategory = elCategory.getChoices();
if ( choicesCategory && choicesCategory.indexOf(current.category) >= 0 )
prob.category = current.category;

} else if (fieldsToBeCopiedFromIncident[i] === 'subcategory') {
var elSubcategory = prob.getElement("subcategory");
var choicesSubcategory = elSubcategory.getChoices(current.category);
if ( choicesSubcategory && choicesSubcategory.indexOf(current.subcategory) >=0 )
prob.subcategory = current.subcategory;

} else if (prob.isValidField(fieldsToBeCopiedFromIncident[i])) {
prob[fieldsToBeCopiedFromIncident[i]] = current[fieldsToBeCopiedFromIncident[i]];

} else {
gs.addErrorMessage(gs.getMessage("{0} is not a valid field in Problem", fieldsToBeCopiedFromIncident[i]));
return undefined;
}
}
return prob;
},

HI,

You dont have to change any code in UI Action and script include. 

ONly thing you have to do is create property with the name i said. And add the field in this property which you want to copy to problem from incident like below:

assignment_group,caller_id,ci,short_description,description

 

You can add many fields.


Thanks,
Ashutosh

Hi @Ashutosh Munot 

In my system, "com.snc.problem.create_from_incident.attributes" property and the entire "Problem > Administration > Problem Properties" module is not found. Can you please tell me why this property and its respective modules are not found .

Also, without this property, the problem is getting created from incident with all the fields - short description, description, assignment group, etc. Can you please tell me how this is happened?

Regards,

PP