Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to copy photo from user table to live_profile table

Shivam32
Tera Contributor

I have created below script which is working fine and copying attachments from user table to live_profile table.

But the issue is it is not creating entry in sys_attachment table.

I have a requirement that when attachment is copy from user table to live_profile table it should create record in sys_attachment table.

Could someone help how could we achieve this.

 

var query = 'user_name=atutuor';
var profileUser = new GlideRecord('sys_user');
profileUser.addEncodedQuery(query);
profileUser.query();
while(profileUser.next()) {
var userUser = new GlideRecord('live_profile');
userUser.addQuery('document',profileUser.sys_id);
userUser.query();
if(userUser.next()){
userUser.setValue('photo',profileUser.photo);
userUser.update();
userUser.setWorkflow(false);
}

4 REPLIES 4

Maik Skoddow
Tera Patron
Tera Patron

Broken link here.  Can you update, @Maik Skoddow ?

Hi @David Lundy ,

 

I believe this is the docs link that Maik provided above: https://www.servicenow.com/docs/csh?topicname=r_UsefulAttachmentScripts.html&version=latest 

RaghavSh
Mega Patron

Try changing below:

 

userUser.setValue('photo',profileUser.getDisplayValue(“photo”));


Raghav
MVP 2023
LinkedIn