how to restrict incident creation from calendar invites for DL

RudhraKAM
Tera Guru

As of now we are creating an Incidents via Inbound action , but when there is a calendar invite , still it is creating Incident , How to restrict that ?

 

I am not able to restrict subject , as it can be any 

 

RudhraKAM_0-1764942196011.png

 

13 REPLIES 13

(function() {
    // 1. Set your Change Request number
    var changeNumber = 'CHG0030001'; 
    
    // 2. Target the field name. 
    // Standard out-of-the-box field is 'production_change'. If custom, it's usually 'u_production_change'.
    var fieldName = 'production_change'; 

    var chgGr = new GlideRecord('change_request');
    chgGr.addQuery('number', changeNumber);
    chgGr.query();

    if (chgGr.next()) {
        // 3. Bypass business rules and system fields to ensure a clean data patch
        chgGr.setWorkflow(false);   
        chgGr.autoSysFields(false); 

        // 4. Set the boolean field to true
        chgGr.setValue(fieldName, true);
        chgGr.update();
        
        gs.print('Success: Set ' + fieldName + ' to true for ' + changeNumber);
    } else {
        gs.print('Error: Change Request ' + changeNumber + ' not found.');
    }
})();

pratyusha11
Tera Contributor
{
  "qa_attestation": "state=3^typeINnormal,expedited^closed_atONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()^production_system=true^close_code!=no_work_performed",
  "infrastructure_attestation": "state=3^change_task_type=testing^u_sub_typeINinfrastructure,infrastructure_no_test_plan^change_request.production_system=true^change_request.close_code!=no_work_performed"
}

pratyusha11
Tera Contributor
var queryChg = (JSON.parseOrNull(gs.getProperty('change.attestation.filter.conditions')) || {}).qa_attestation || '';

pratyusha11
Tera Contributor
(function() {
    // 1. Specify the Change Request number and your desired new closed date/time
    var changeNumber = 'CHG0030001'; 
    var newClosedTime = '2026-05-25 14:30:00'; // Must be in YYYY-MM-DD HH:MM:SS format (UTC)

    // 2. Query for the specific Change Request record
    var chgGr = new GlideRecord('change_request');
    chgGr.addQuery('number', changeNumber);
    chgGr.query();

    if (chgGr.next()) {
        // 3. Configure the record to bypass background logic during this manual fix
        chgGr.setWorkflow(false);   // Prevents business rules, workflows, and notifications from firing
        chgGr.autoSysFields(false); // Prevents 'sys_updated_on' and 'sys_updated_by' from changing

        // 4. Update the closed time field
        chgGr.setValue('closed_at', newClosedTime);
        
        // Optional: If you also need to update the 'Closed by' user, uncomment the line below
        // chgGr.setValue('closed_by', 'sys_id_of_user'); 

        // 5. Commit the change to the database
        chgGr.update();
        
        gs.info('Fix Script Success: Updated closed time for ' + changeNumber + ' to ' + newClosedTime);
    } else {
        gs.error('Fix Script Error: Change Request ' + changeNumber + ' not found.');
    }
})();

(function() {
    // 1. Set your Change Request number
    var changeNumber = 'CHG0030001'; 

    // 2. Define closing values (Out-of-the-box defaults)
    var closedState = '3'; // '3' is standard for Closed in the Task/Change tables
    var closeCode = 'successful'; // Common choices: successful, successful_issues, unsuccessful
    var closeNotes = 'Closed via administrative background script data patch.';

    var chgGr = new GlideRecord('change_request');
    chgGr.addQuery('number', changeNumber);
    chgGr.query();

    if (chgGr.next()) {
        // OPTION A: Clean Data Patch (Recommended for old/stuck changes)
        // Bypasses workflows/notifications so it doesn't spam users or break metrics
        chgGr.setWorkflow(false);   
        chgGr.autoSysFields(false); 

        // OPTION B: Run Business Logic (Uncomment the two lines below if you WANT 
        // notifications to send, cascading closures to tasks, and normal rules to run)
        // chgGr.setWorkflow(true);
        // chgGr.autoSysFields(true);

        // 3. Set the state and mandatory closing fields
        chgGr.setValue('state', closedState);
        chgGr.setValue('close_code', closeCode);
        chgGr.setValue('close_notes', closeNotes);
        
        // Sets the closure timestamp to right now
        chgGr.setValue('closed_at', new GlideDateTime()); 

        chgGr.update();
        gs.print('Success: ' + changeNumber + ' has been set to Closed.');
    } else {
        gs.print('Error: Change Request ' + changeNumber + ' not found.');
    }
})();