We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Inbound action script help for stripping only computer name

RudhraKAM
Tera Guru

Hello I need to create an Incident when an Email from xyz is being sent to servicenow , but email might have some computer names which I need to only get those names and set it in Description of Incident , 

Below is the email which we will get and we only want computer names under Problematic BCA clients . 

Thanks in advance 

 

RudhraKAM_0-1738174506132.png

 

 

12 REPLIES 12

@RudhraKAM  You can build regex here and use match() to retrieve the computer name data. 

 

Doc link for further details.

String.prototype.match() 

 

Thanks

Harsh

 

(function() {
    // 1. Specify the Sys ID of the record producer you want to update
    var recordProducerSysId = 'YOUR_RECORD_PRODUCER_SYS_ID'; 
    
    // 2. Specify your target timestamp (Format: YYYY-MM-DD HH:MM:SS in UTC)
    var newCreatedTimestamp = '2025-07-09 08:44:00'; 

    var grProducer = new GlideRecord('std_change_record_producer');
    if (grProducer.get(recordProducerSysId)) {
        
        // Disable automatic updating of system fields (sys_updated_by, sys_updated_on, sys_created_on, etc.)
        grProducer.autoSysFields(false); 
        
        // Set the new creation timestamp
        grProducer.setValue('sys_created_on', newCreatedTimestamp);
        
        // Execute the update
        var success = grProducer.update();
        
        if (success) {
            gs.print('>>> [SUCCESS] Updated sys_created_on to ' + newCreatedTimestamp + ' for Record Producer: ' + grProducer.getDisplayValue());
        } else {
            gs.print('>>> [ERROR] Failed to update the record producer.');
        }
    } else {
        gs.print('>>> [ERROR] Record Producer with Sys ID ' + recordProducerSysId + ' could not be found.');
    }
})();

ChrisBurks
Giga Sage

What's the HTML structure behind the email and aside from the count of computer names that might appear is the structure consistent?

pratyusha11
Tera Contributor
function onLoad() {
setTimeout(function() {
var parentValue = g_form.getValue('task_number');

if (parentValue) {
var ga = new GlideAjax('GetChangeInfo');
ga.addParam('sysparm_name', 'getChangeDetails');
ga.addParam('sysparm_change_id', parentValue);
ga.getXMLAnswer(function(response) {
if (response) {
var obj = JSON.parse(response);
if (obj.is_chg) {
if (obj.short_description) {
g_form.setValue('short_description', obj.short_description);
}
if (obj.cmdb_ci) {
g_form.setValue('cmdb_ci', obj.cmdb_ci);
}
}
}
});
}
}, 10);
}

RudhraKAM
Tera Guru

(function executeRule(current, previous) {
// 1. Define the property name
var propertyName = 'wf.change.success.score.icon.visibility';

// 2. Get the comma-separated list of roles from the property
var requiredRoles = gs.getProperty(propertyName);

// 3. Set the default visibility to false
g_scratchpad.showButton = 'false';

// 4. Check if the property has a value (roles specified)
if (requiredRoles) {
// 5. Check if the current user has ANY of the required roles
// gs.hasRole() can take a comma-separated string of roles.
if (gs.hasRole(requiredRoles)) {
g_scratchpad.showButton = 'true';
}
}

})(current, previous);