Autopopulate country in child locations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:16 AM
Hello Experts,
In locations(cmn_location) table if location type(dropdown) = country then i want to populate name(string) value into Country(string)field then at the same time I want to update Country field in child records as well.
Child records means state ,city,site,etc....
How to achive this by using onload client script.
Thanks in advance,
Best Regards,
Nani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:27 AM
Hi @Nani18
Please write a OnLoad CS .
function onload() {
// Get the current location record.
var location = cmn_location.getCurrentLocation();
// Check if the location type is country.
if (location.location_type == "Country") {
// Get the country name.
var countryName = location.name;
// Update the country field in the child records.
var childRecords = cmn_location.getRelatedRecords("cmn_location", "child_locations");
for (var i = 0; i < childRecords.length; i++) {
childRecords[i].country = countryName;
}
}
}
Please mark the answer as correct solution and helpful if helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:36 AM
Hello @nameisnani
Thanks for your help.
I tried with Business rule it is working only on insert or update .. I am new to scripting , is there any possibility to change this script to onload client script with the same fields..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:37 AM
Hi @Nani18
I have already given a Onload Client script . Please check .
Please mark the answer as correct solution and helpful if helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:48 AM