- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2016 08:32 AM
We are currently populating a field on our User table from Okta called 'mobile_phone'. I need to copy this data to a reference field called 'u_affiliate'. I don't want the update to happen if the mobile_phone field is empty. I tried to do this as a Business Rule when the record is updated/inserted but couldn't get it to work. Does anyone know how I might achieve this? Alternatively I could schedule a script to run nightly instead of a BR but I don't know how to do that either. Any help is much appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2016 11:43 AM
Thanks Wayne for the update. Please create a before business rule with below script.
var gr = new GlideRecord('u_affiliates');
gr.addQuery('field column name', current.mobile_phone);
gr.query();
while(gr.next())
{
current.u_affiliates = gr.sys_id;
}
NOTE : Replace field column name in line 2 with the exact field column name and make sure all column names and table name are adjusted properly.
Please let me know if you are blocked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2016 05:00 AM
Is there a field called mobile phone in the 'u_affiliates' table too? If yes
Business Rule
table : sys_user
when : before Insert/Update
Advanced : true
Filter condition : mobile_phone field is not empty
var gr = new GlideRecord('u_affiliates');
gr.addQuery('mobile_phone', current.mobile_phone);
gr.query();
if(gr.next()){
current.u_affiliate = gr.sys_id;
}