- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2022 12:48 PM
Here is the code I have that verifies the value is synced. I added the if and for statement because it work 90% of the time and the other 10% failed. I think it might be a timing issue so I added the for and if statements however now it hangs - Thoughts?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var cc = g_form.getReference('cost_center', populateReqForDetails);
function populateReqForDetails(cc) {
for (i = 0; i < 5; i = i++) {
if (cc == 'u_cost_center_code') {
return;
} else {
g_form.setValue('u_cost_center_code', cc.code);
}
}
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 08:17 AM
From any Department record, select Configure > Form Layout
From there, click the Cost center [+] field, then select the top icon in the middle to expand the Cost center [+] to show all fields on the Cost Center form.
Select the Code field and add it to your form.
You probably should make the field read only with a UI Policy so users do not change the Cost center record by mistake:
- Make Code Read Only
Table: Department [cmn_department]
Short description: Make Code Read Only
Description: Makes the Code field from the Cost Center record read only
Order: 100
Global: true
Reverse if false: true/false
On load: true/false
Inherit: true/false
Create a UI Policy Action and expand the Cost center field to get at the Code field
Make the UI Policy Action for the Code field to be Read only
Let me know if you still need assistance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 12:40 PM
Also they are not the same field - cost_center is a string of the name - u_cost_center_code is the number that represents the cost_center - the people using this deal with numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 01:01 PM
This sounds more like they want to search on a cost center number rather than the display value of the cost center. Is this correct. There is no need to create some synch mechanism when what you want is to use an auto completer. Using your field from the cost center table as an example, place the following into the Attributes section of your reference field:
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=u_cost_center_code,ref_ac_columns_search=true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 09:22 AM
That is correct - so I would put that code on my custom u_cost_center_code field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 09:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 10:02 AM
Here what I have - I have the OOB department table which shows the display value of Cost Code (it is a reference to the Cost Center table). I have a custom String field that I have put on the form called u_cost_center_code which was put there to synch to get the actual code for the displayed Cost Code.