Category: Scenario based QA - 14
Updated on: August 9, 2025  |  0

Scenario-Based Questions PART 14

🎓 Scenario-Based Questions

Q1: Is it possible to update a record without updating its system fields (like sys_updated_by, sys_updated_on)?

✅Answer:

✅Yes, you can achieve this by using the function autoSysFields(false) in your server-side script. This prevents system fields from being updated during the record update.


var gr = new GlideRecord('incident');
gr.query();
if (gr.next()) {
  gr.autoSysFields(false);
  gr.short_description = "Testing";
  gr.update();
}

  
🧠 Pro Tips:autoSysFields(false)
  • disables the automatic update of system audit fields for that update operation.Useful for making silent updates without changing
sys_updated_on
  • ,
sys_updated_by
  • , etc.Be cautious when using it, as skipping system fields update impacts audit trails and record history.

Q2: How to pass data from one widget to another widget?

✅Answer:

We can use $emit, $broadcast, and $on to send and receive data between widgets in Service Portal.

📡 Example using $broadcast:

Source Widget (Client Controller):


$rootScope.$broadcast('dataEvent', data);

  

Target Widget (Client Controller):


$scope.$on('dataEvent', function (event, data) {
  console.log(data); // 'received data'
});

  

📡 Example using $emit:

Source Widget (Client Controller):


$rootScope.$emit('dataEvent', id);

  

Target Widget (Client Controller):


$scope.$on('dataEvent', function (event, data) {
  console.log(data); // 'received data'
});

  
🧠 Pro Tips:
  • $broadcast sends the event downwards from the root scope to child scopes.
  • $emit sends the event upwards from the current scope to parent scopes.
  • Use $on to listen for these events and handle data accordingly.
  • Ensure both widgets are within the same scope hierarchy for communication to work.

Comments

No comments yet.


Log in to post a comment