Service Desk Practitioners Forum
cancel

Rule to find CI searchcode based on custom field

SOLVED
Go to solution
Highlighted
dmann
Super Contributor.

Rule to find CI searchcode based on custom field

I want to find a CI name from an incident created from OVO, with sd_event.

I have created a custom field in incident called jobnae
I have created a custom field in configuration items called jobname.
I have also added a CI named jobfailure.

Sdevent will create a ticket with one CI called jobfailure, and pass the job name in a custom field called jobname. ( I still working on this piece)

I want to create a database rule which checks for the jobname then changes the CI to what the appropriate job name ci.

On incident create, if the CI is jobfalure and the jobname filed has anything, then find the CI where the “incident jobname”=”CI jobname” and populate the CI with the new ci search code.

The first part On incident create, if the CI is jobfalure and the jobname filed has anything, is easy.

I cannot figure out the last part. IS this possible?

, then find the CI where the “incident jobname”=”CI jobname” and populate the CI with the new ci search code.

What would the data update in the rule look like?
11 REPLIES
George M. Meneg
Acclaimed Contributor.
Solution

Re: Rule to find CI searchcode based on custom field

Hello Bill,

It can be done (on OVSD 4.5) but it is tricky, it is based on a bug and it is not sure if this will continue working on the new sp.

The db rule should be created as usual;

When incident is created
where Configuration Item equals jobfailure
Update CI (Update Data) Configuration Item;Searchcode set to [jobname]

When enter that DO NOT press NEXT. Select the Update action from the action list (In this example "Update CI") and press "Modify..."

Open the action and select from the list the action you previously entered. Go to the input box below the "Fields Button" and delete ;Searchcode. You will notice that the value is cleared. Press Cancel.

The rule now should be like:

When incident is created
where Configuration Item equals jobfailure
Update CI (Update Data) Configuration Item set to [jobname]
menes fhtagn
George M. Meneg
Acclaimed Contributor.

Re: Rule to find CI searchcode based on custom field

...which is what you want :)
menes fhtagn
dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

George,

Thanks for the quick response.

I tried this it did not work. I think I may have not been clear. See OVO watches a log file which contains jobnames. These names have characters which cannot be a searchcode. (Mostly underscores). I want to load the jobs in a custom field. I can create unique searchcodes for each job. But those unique names will not be in the log file, and therefore I cannot use them.

The jobname field will not contain a valid CI name. However, a CI will have the data in the jobname field. I am trying to lookup the correct CI name from the name field.

CI Searchcode CustomJobNameField
ADOBEACROBAT Adobe_acrobat
THISISCINAMEFORJOB special_job_1

For example, I have an incident and special_job_1 fails. Sd_event then runs and the paratemers are the following:


Ci searchcode=JOBFAILURE

Ci searchcode=specialjob1
Ci custom field jobname = special_job_1

A ticket is created with JOBFAILURE as the ci. I want to replace the searchcode JOBFAILURE with the searchcode specialjob1. I must lookup in the jobname field special_job_1 because I do not know the searchcode. When I find the special_job_1 in the jobname field, I then need to get the actual searchcode.


George M. Meneg
Acclaimed Contributor.

Re: Rule to find CI searchcode based on custom field

The solution to this is very simple. Just rename the values of your custom fields and replace "_" with "-".

For example
Ci searchcode=special-job-1
Ci custom field jobname = special_job_1

Then in the db rule use substitute for in order to convert "_" to "-"

Update CI (Update Data) Configuration Item set to (Substitute for [jobname] String _ With -)
menes fhtagn
dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

OK. I put in place:

Database Rule
Item type: Database Rule
Name: Job CI Update
Blocked: No
Category: Integration
Condition: When incident is created
OR When incident is modified
where NOT (JobName (*) is empty)
AND Configuration Item equals JOBFAILURE
Actions: Job CI Update (Update Data) Configuration Item;Search code set to (Substitute for [JobName] String _ With -)

This is what happens in the log file


Tue, 12/12/2006 10:43:38 Rule "Job CI Update" condition: NOT (JobName (*) is empty) (value: special_job_1): true
Tue, 12/12/2006 10:43:38 Rule "Job CI Update" condition: Configuration Item equals JOBFAILURE (value: JOBFAILURE): true
Tue, 12/12/2006 10:43:38 Rule "Job CI Update" was valid, execute the actions

Nothing happens.

The CI is not updated.
George M. Meneg
Acclaimed Contributor.

Re: Rule to find CI searchcode based on custom field

Hello

The
<<
Open the action and select from the list the action you previously entered. Go to the input box below the "Fields Button" and delete ;Searchcode. You will notice that the value is cleared. Press Cancel.
>>

part is critical. If you don't do that what you do is to change the CI's searchcode and not change Ci.
menes fhtagn
dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

I look at it some more:

I tried a couple of things.

1. added a new rule which populates information with the replacement logic:

Database Rule
Item type: Database Rule
Name: Copy of Job CI Update
Blocked: No
Category: Integration
Condition: When incident is created
where NOT (JobName (*) is empty)
AND Configuration Item equals JOBFAILURE
Actions: Job CI Update (Update Data) Solution set to [JobName]; Information set to (Substitute for [JobName] String _ With -)

special-job-1


Also: I put search code back in:
Database Rule
Item type: Database Rule
Name: Job CI Update
Blocked: No
Category: Integration
Condition: When incident is created
where NOT (JobName (*) is empty)
AND Configuration Item equals JOBFAILURE
Actions: Job CI Update (Update Data) Configuration Item;Search code set to (Substitute for [JobName] String _ With -)

This does not update the CI searchcode in the incident.

dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

OK...

Database Rule
Item type: Database Rule
Name: Job CI Update
Blocked: No
Category: Integration
Condition: When incident is created
where NOT (JobName (*) is empty)
AND Configuration Item equals JOBFAILURE
Actions: Job CI Update (Update Data) Configuration Item set to (Substitute for [JobName] String _ With -)


Database Rule
Item type: Database Rule
Name: Copy of Job CI Update
Blocked: No
Category: Integration
Condition: When incident is created
where NOT (JobName (*) is empty)
AND Configuration Item equals JOBFAILURE
Actions: Job CI Update (Update Data) Solution set to [JobName]; Information set to (Substitute for [JobName] String _ With -)


And the answer is:

It looks like it worked!

Tue, 12/12/2006 11:10:57 Rule "Job CI Update" condition: NOT (JobName (*) is empty) (value: special_job_1): true
Tue, 12/12/2006 11:10:57 Rule "Job CI Update" condition: Configuration Item equals JOBFAILURE (value: JOBFAILURE): true
Tue, 12/12/2006 11:10:57 Rule "Job CI Update" was valid, execute the actions
Tue, 12/12/2006 11:10:57 Rule "Copy of Job CI Update" condition: NOT (JobName (*) is empty) (value: special_job_1): true
Tue, 12/12/2006 11:10:57 Rule "Copy of Job CI Update" condition: Configuration Item equals JOBFAILURE (value: JOBFAILURE): true
Tue, 12/12/2006 11:10:57 Rule "Copy of Job CI Update" was valid, execute the actions


I recreated the rule; stoppped and started the SD.
dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

I got one to work with an updated CI.

I need to test on SD_event now.

Will update thread and points.
dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

We are still getting to the testing of this solution.

Thanks for the patience.
dmann
Super Contributor.

Re: Rule to find CI searchcode based on custom field

This solution has been implemented in production.

The OVO uses sd_event to create the inicdent ticket. A generic jobfailure CI is used to create the ticket. The DB rules are tiggered on the jobfailure ci, lookup the CI, if it is found then it replaces the jobfailure CI with the jobname. If not, it is saved as jobfailure.

This solution was a nice win for me.

THANKS