
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 02:26 PM
Hi,
I tried to create an discovery pattern for a network device.
I read in a display value of the firmware_manufacturer via SNMP Query.
With this name I will set a reference to core_company in CI. If I write the display value in the field via pattern operation "Set Value", I get something like that:
<firmware_manufacturer display_value="">Aruba</firmware_manufacturer> after discovery.
But I want to have that: <firmware_manufacturer display_value="Aruba">sys_id_of_company</firmware_manufacturer>
How can I reach that in a pattern?
Greets, Daniel
Solved! Go to Solution.
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 06:37 AM
Daniel,
Check out the blog post I just put together.
Using Pre/Post Processing Scripts to handle reference fields via Discovery Pattern
I hope this solves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2024 11:05 PM - edited ‎05-01-2024 11:27 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2018 11:19 PM
I temporarily solved it with a before update Business Rule. This replaces values in reference fields if it does not contain sys_ids. But I would be happier if there was something within the pattern approach.
(function executeRule(current, previous /*null when async*/) {
//Display an information message for each change to the record
var gru = GlideScriptRecordUtil.get(current);
var changedValues = gru.getChangedFieldNames(); //Get changed field values
//Convert to JavaScript Arrays
gs.include('j2js');
changedValues = j2js(changedValues);
//Process the changed fields
for(var i = 0; i < changedValues.length; i++){
var val = current[changedValues[i]];
var elemDesc = val.getED();
if(elemDesc.getInternalType() == "reference" ){
var value = val.getValue();
var regexp = /([0-9a-f]{32})/;
if(value.match(regexp) == null){
current.setValue(elemDesc.getName(),"");
current.setDisplayValue(elemDesc.getName(),value);
}
}
}
})(current, previous);
I set the value as display_value and after an update the system will replace the reference correctly with the sys_id.
Is nobody here who knows a better approach within the patterns self?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 08:43 AM
Hi Daniel,
What I have been told by SN developers, you can use either a post or pre sensor script. Pre is to mod the payload before record gets submitted to DB, Post is to update record after its been submitted to DB.
Give me a few hours and Ill update my post with examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 12:15 AM
Thanks for your answer Patrick. I'm looking forward for your examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 06:37 AM
Daniel,
Check out the blog post I just put together.
Using Pre/Post Processing Scripts to handle reference fields via Discovery Pattern
I hope this solves your issue.