- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:08 AM
If short Description : Registered as y_6778 journey
Field name : Key (string)
My question is I need populate the "y_6778" value in key field. How to approach.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:32 AM - edited 04-25-2024 03:33 AM
Hi @AJAYKUMAR G ,
As you have not mentioned that when do you need this to take place , i assume that you need it when the record is updated or create / if its on change of field on form then you can use onchange client scipt or if on insert or update you need to use business rule.
for client script :
function onChangeShortDescription(control, oldValue, newValue, isLoading) {
if (newValue && newValue.startsWith("y_")) {
var match = newValue.match(/y_\d+/);
if (match) {
var extractedValue = match[0];
g_form.setValue('key', extractedValue);
}
}
}
if its business rule :
(function executeRule(current, previous /*null when async*/) {
if (current.short_description.changes() && current.short_description.startsWith("y_")) {
var match = current.short_description.match(/y_\d+/);
if (match) {
var extractedValue = match[0];
// Set the extracted value into the key field
current.key = extractedValue;
}
}
})(current, previous);
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:20 AM
Hi @AJAYKUMAR G,
This is easily achieved with an onChange Client Script.
See the below script and screenshot for guidance.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var valToComapre = newValue;
var matchFound = valToComapre.match('y_6778');
if(matchFound){
g_form.setValue('your_field_name', matchFound);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:25 AM
Not exact value I have given .. it like starts y_
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:58 AM
Hi @AJAYKUMAR G,
I thought it was too specific and literal...
Tweak the onChange script to the below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var valToComapre = newValue;
var containsVal = valToComapre.indexOf('y_');
if(containsVal > -1){
var result = newValue.slice(containsVal).trim().split(' ')[0];
g_form.setValue('your_field_name', result);
}
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 04:52 AM
Here you mentioned as start with y_ > 🙂
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....