Account creation logic

Mike6
Giga Contributor

Hi all!

I need some help with creating customer accounts in my instance.

Because of the OOTB logic of the account table (customer_account) being extended of the core_company table, logic dictates that records are created on the company table after creating an account record. The issue is that I'm working in an instance that is already being used for a couple of years now. So there are already company records in the system and I don't want to create duplicates. Removing (replacing) the original core_company records is not an option either as you will also lose your references in other parts of the system (e.g. on Incidents).

What can I do to link an account record to an existing company record?

Thanks in advance!

1 ACCEPTED SOLUTION

Mike6
Giga Contributor

Found a workaround. I created a background script to query for the right core_company records, and update the class:

//Fetch the record:
var gr = new GlideRecord('core_company');
gr.[insert query here];

//Switch the class:
if (gr.next()) {

	gr.sys_class_name = "customer_account";
}

//Update the record (without triggering additional business rules (optional)):
gr.setWorkflow(false); //Optional.
gr.update();

It does what I need it to do and keeps all references intact. Yet this is but a workaround. A proper OOTB solution to this logical loophole would be welcome.

View solution in original post

7 REPLIES 7

Mike6
Giga Contributor

Found a workaround. I created a background script to query for the right core_company records, and update the class:

//Fetch the record:
var gr = new GlideRecord('core_company');
gr.[insert query here];

//Switch the class:
if (gr.next()) {

	gr.sys_class_name = "customer_account";
}

//Update the record (without triggering additional business rules (optional)):
gr.setWorkflow(false); //Optional.
gr.update();

It does what I need it to do and keeps all references intact. Yet this is but a workaround. A proper OOTB solution to this logical loophole would be welcome.

It's not really a workaround, but is actually the proper way to do it for existing Company records with the use of the Customer Service app now.

Jim Coyne
Kilo Patron

Did you find a solution to your issue?  If yes, please remember to tag the correct answer (even if your own) and any that were helpful.