The CreatorCon Call for Content is officially open! Get started here.

Populate the image in incident form.

subashds6515
Tera Contributor

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.
3 REPLIES 3

Bert_c1
Kilo Patron

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:

 

Screenshot 2023-07-01 154311.png

 

Using a client Script will require the use of GlideAjax to query the sys_user table for the user's photo.

Hi @Bert_c1 ,

I tried this one, but it's not working.

 

Thanks,

Bert_c1
Kilo Patron

Hi @subashds6515 

 

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)?