Populate the image in incident form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2023 06:10 AM
Use the business rule to populate the caller picture in incident form.
- In incident form, fill the caller's picture based on the caller.
I have created a new field in the incident form, and the field type is image.
- I tried with the client script, but it's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2023 12:46 PM
Hi @subashds6515',
Business Rule logic follows:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var sur = new GlideRecord('sys_user');
sur.addQuery('sys_id', current.caller_id);
sur.query();
// gs.info("copyCallerPhoto: Found " + sur.getRowCount() + " user records.");
if (sur.next()) {
current.u_caller_photo = sur.photo;
// gs.info("copyCallerPhoto: image = " + sur.photo + ".");
}
})(current, previous);
Defined on the incident table , see below:
Using a client Script will require the use of GlideAjax to query the sys_user table for the user's photo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 09:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 10:12 AM
I tested that in my PDI, and it works fine.
1. what is the name of your custom field, type image, on the incident table?
2. Un-comment the two 'gs.info()' lines, test, then look in Script log Statements for message starting with "copyCallerPhoto".
3. what is the name of the image field in the sys_user table that you want? I have 'photo' and 'avatar' defined in my PDI. Note, not all records in my sys_user table have a non-null photo field value. I tested with multiple users, those that had a value for photo did appear on the incident form.
4. did you create the BR as 'admin' user (or a user with the proper permissions)?