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.

convert user to contact

Alexis Osborne
Tera Contributor

We have a need to convert an existing User record to a Contact.    

We wrote a script that would identify these User records as they are created and it updates the class on the sys_user = 'customer_contact'.    

While the update works, the corresponding customer_contact row is not created.  This leaves the user row in a bad state.   You can no longer view the record in the gui - it returns record not found due to the missing customer_contact row.

I've tried writing a script to insert the customer_contact row with the same sys_id as the sys_user record.  This fails with a primary key violation.   Not surprising as it should be trying to also insert a sys_user record with the creation of the customer_contact row.   Where it already exists, that creates the primary key violation.

We are not able to change how these users are created initially - they are being automatically created by SN when an email is received.   I know, not good.  But we are stuck with this.  Too much built upon it to untangle.

Anyway.. I've figured out a lot of ways that won't fix this.   I need your help.  How can we convert the existing User records to Contacts so that the customer_contact row is created for them?

Thanks in advance...

 

 

 

 

1 REPLY 1

IbrahimVali
Tera Guru

Hi there,

Here is the simple way,

Step 1: Go to users list

step 2: Personalize list [edit gear icon] and add 'Class' field to the list and save

step 3: Edit Class value from 'User' to 'Contact' [as shown below]

find_real_file.png

step 4: It is converted as contact, now you can navigate to contacts and find this contact in the list.

NOTE: 1. We can also change a 'Contact' as 'User' by following the above steps.

2. A contact will store in Contact table and User table as well, since it is extended from User table.

- If my answer helps you, please mark it as "Correct Answer"

Regards,

Ibrahim