Business Rule to Autopopulate Image Field

alexcharleswort
Tera Expert

Hi all,

It appears I am having issues populating an image field based off of the changes on another field. I have a true/false field on my u_business_cards table called u_chairman. What I need to have happen is if u_chairman changes to true then autopopulate u_chairman with a specific image that I put on the db_image table.

I was able to do this with another application but I can't seem to replicate it. What I have done so far is create a Before Business Rule on insert or update. The filter says u_chairman -- is -- true.

The script that I have in there looks like this....

find_real_file.png

I know the business rule itself is working because u_ext shows "test" when I update the record.

"0b8b3e4d4fafd7007dc7ea7d0210c786" is the sys_id of the record on the db_image table.

I'm really not sure what could be missing here. If anyone has ideas, let me know!

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

alexcharleswort
Tera Expert

Well... upon even further digging, looks like you may only be able to transfer the attachment to the image field if your image fields are called the same thing... which meant I had to make another image field on db_image table just called u_image and change my variable on my custom table to u_image. Then it worked fine. Just couldn't figure out how to use the original image variable from the db_image table.

View solution in original post

4 REPLIES 4

alexcharleswort
Tera Expert

Well... upon even further digging, looks like you may only be able to transfer the attachment to the image field if your image fields are called the same thing... which meant I had to make another image field on db_image table just called u_image and change my variable on my custom table to u_image. Then it worked fine. Just couldn't figure out how to use the original image variable from the db_image table.

Hi @alexcharlesworth ,

Can you please provide the exact code?

Regards,

Alok sahu

alexcharleswort
Tera Expert

(function executeRule(current, previous /*null when async*/) {

// Add your code here
GlideSysAttachment.copy("ZZ_YYdb_image", "797f7532dbaf5b0c2df7499e0b961928", "ZZ_YYu_business_cards", current.sys_id);

})(current, previous);

 

This was my final code. But, like I said, I had to have a u_image field on my custom table and u_image field on the db_image table for it to work. 

Hi,

I added the custom field on both the tables (custom and db_image table) but still it is not working.

Do we need to do any configuration?

Regards,

Alok sahu