Please tell me the script to realize below function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 04:49 PM
Hi, I'm Kei.
I would like to implement the below function.
I'm not good at Java Script.
That's why I would appreciate it if you could let me know the script.
<Function>
If the field of "Kitting Price" (api name:k_price) is 8500, the field of "Kitting" (api name:kitting ) can be value "standard"
If the field of "Kitting Price" (api name:k_price) is 11000, the field of "Kitting" (api name:kitting ) can be value "choice"
I would like to set the above script in the calculated Value of "Kitting Price" field.
And I have already created two records(Value 8500 record & Value 11000 record) in system_property table.
It seems to use the method gs.getProperty, but I'm not sure...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 07:03 AM - edited 02-16-2024 07:30 AM
Hi,
Not a lot to go on but, if assume a Business Rule, then the code should be something like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 08:02 AM
Hi @Kei Ogose
Really depends how its updated. If its being updated from another table I'd say go with a business rule like below.
Run: Before on Insert/Update
(function executeRule(current, previous /*null when async*/ ) {
var k_price = current.k_price;
var knitting = current.knitting;
if (k_price == 8500) {
current.knitting = 'standard';
} else if (k_price == 11000) {
current.knitting = 'choice';
}
})(current, previous);
Otherwise if its being updated in the client, go with this on change client script.
Run when k_price Changes
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var k_price = g_form.getValue('k_price');
var knittingf = g_form.getControl('knitting');
if (k_price == 8500) {
knittingf.value = 'standard';
} else if (k_price == 11000) {
knittingf.value = 'choice';
}
}
Please mark as helpful or if its resolved the issue, CORRECT!