Create a business rule to move all the data from the existing an existing field to a new Field

Nathan Okh
Mega Sage

Hello I have a requirement to Create a business rule to move all the data from the existing Configuration items field to the newly created custom field "Old configuration item" for all incidents.

Can anyone help?

4 REPLIES 4

Mike_R
Kilo Patron
Kilo Patron

Business rules only run when records are inserted or updated. I can help create the rule.

But are you looking for a one time scheduled job instead, to bulk update?

Thats awesome! Thanks.

It depends on whats best practice and/or logical. A scheduled job/import/bulk update. What do you think?

But what we are trying to accomplish is eliminating duplicate CI's that were created due to a Legacy customization and SG-Intune scheduled jobs...

Essentially, I created a new field called "Old Configuration Item" which we needs to be filled with the current Configuration Item on the Incident. And from there, there is more to do...

These are the steps I'm following for my current situation and I need help with the Second Step, so i'm changing this up a bit. 

Step 2 is where i need help

 

Step 1

- Export the existing CIs as they are to a CSV file.

- Create a new data source under the SG for intune

- Use the previously downloaded CVS as the source data

- Create a transform map and map the old data accordingly and import it to the CI table.

 

Step 2

Create a business rule to link the old incidents to the correct CI based on the manual process your team would normally follow for an incident without an associated CI.

 

This approach would ensure that you retain your old data in a CSV file and they would be in the correct format once they are imported.

Mike_R
Kilo Patron
Kilo Patron

Below is some untested code that you can try this in a fix script. Obviously test in sub-prod first. This will populate the new field with the values from the configuration item field.

 

 

var inc =  new GlideRecord('incident');
inc.addEncodedQuery('cmdb_ciISNOTEMPTY');
inc.query();
while(inc.next()){
	inc.u_new_ci_field_name = inc.cmdb_ci; // replace u_new_ci_field_name  with your new field name
	inc.setWorkflow(false);
	inc.autoSysFields(false);
	inc.update();
}