how to force new Manufacturer records into the global domain.

Kris Jensen
Tera Guru

We now have a business need to make sure all new Manufacturer records are in the global domain.  Currently the records is created in the domain of the person creating the record.  Other than that, the manufacturer record is sent to the default domain.  How do I code for this? 

 

This is our current business rule -

 

On Insert where Manufacturer = true

Code -

 

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

    // Add your code here
    gs.info('Kris - old domain path = '+current.sys_domain_path);
    if(current.sys_domain_path != '/'){
        current.sys_domain_path = '/';
        current.update();
        gs.info('Kris - new domain path = '+current.sys_domain_path);
    }
   


})(current, previous);
1 ACCEPTED SOLUTION

JP - Kyndryl
Kilo Sage

Hi Kris,

A before BR like this one will do the trick:

JPKyndryl_0-1717709642132.png

setGlobalDomain();

function setGlobalDomain() {
//make current transaction uncancelable while this rule runs,
//set variable to previous cancelable state to restore when done
var isCancelable = gs.setCannotCancel(true);
 
current.sys_domain = 'global';

//restore previous cancelable state
gs.setCannotCancel(isCancelable);
}
 
Make sure you set the order to 10,000 to go after the OOTB BR that is setting the domain for a new company.
 
Regards,
JP

View solution in original post

3 REPLIES 3

JP - Kyndryl
Kilo Sage

Hi Kris,

A before BR like this one will do the trick:

JPKyndryl_0-1717709642132.png

setGlobalDomain();

function setGlobalDomain() {
//make current transaction uncancelable while this rule runs,
//set variable to previous cancelable state to restore when done
var isCancelable = gs.setCannotCancel(true);
 
current.sys_domain = 'global';

//restore previous cancelable state
gs.setCannotCancel(isCancelable);
}
 
Make sure you set the order to 10,000 to go after the OOTB BR that is setting the domain for a new company.
 
Regards,
JP

Kris Jensen
Tera Guru

I'll give it a try!

Kris Jensen
Tera Guru

Perfect!!!  Thank you!