- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 03:19 AM
Hi all,
I have a requirement, a description field and quantity field, if on change of quantity , append both field description and quantity and set the value in another field 'C', then clear the value of description field and quantity field, if again on change of quantity , append both field description and quantity and add the value in Variable 'C'.
In my case, while i am setting the value in Variable 'C', each time field is clearing and setting new Value
Is there a way to add the values in the field??
Thanks in advance.
Regards,
Suvedha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 05:21 AM
Hi @Suvedha ,
modify this script is c field value is nill then add directly else append with existing . something like below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var description = g_form.getDisplayValue('description');
var qunatity= g_form.getDisplayValue('quantity');
var c_fieldValue = '';
if( g_form.getDisplayValue('c_field_name') == ''){
c_fieldValue = description + qunatity;
}
else{
c_fieldValue = g_form.getDisplayValue('c_field_name') + "\n\n" + description + qunatity;
}
alert(c_fieldValue );
g_form.setValue("v",c_fieldValue );
g_form.clearValue('description');
g_form.clearValue('quantity');
}
Regards,
Riya Verma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 05:39 AM
Hello @Suvedha
Please find updated script below:
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 03:49 AM
Hi there,
You can create onChange client script on 'Quantity' field with the script as below:
var description = g_form.getValue('description');
var currentFieldC = g_form.getValue('field_C');
g_form.setValue('field_C', currentFieldC + ' ' + description + ' ' + newValue);
g_form.clearValue('description');
g_form.clearValue('quantity'');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 04:39 AM - edited 06-20-2023 04:39 AM
Hi @Suvedha ,
Hope you are doing great.
Try using below modified script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var description = g_form.getDisplayValue('description');
var qunatity= g_form.getDisplayValue('quantity');
var c_fieldValue = '';
c_fieldValue = g_form.getDisplayValue('c_field_name') + "\n\n" + description + qunatity;
alert(c_fieldValue );
g_form.setValue("v",c_fieldValue );
g_form.clearValue('description');
g_form.clearValue('quantity');
}
In this, I have concatenated the value of c field existing value and appended with description and quantity and then set in c field and then later you can clear the value of description and quantity.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 05:10 AM
Hi Riya,
Thanks for your reply.
I am getting the white space in first line.
can we remove this using trim()
Regards,
Suvedha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 05:21 AM
Hi @Suvedha ,
modify this script is c field value is nill then add directly else append with existing . something like below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var description = g_form.getDisplayValue('description');
var qunatity= g_form.getDisplayValue('quantity');
var c_fieldValue = '';
if( g_form.getDisplayValue('c_field_name') == ''){
c_fieldValue = description + qunatity;
}
else{
c_fieldValue = g_form.getDisplayValue('c_field_name') + "\n\n" + description + qunatity;
}
alert(c_fieldValue );
g_form.setValue("v",c_fieldValue );
g_form.clearValue('description');
g_form.clearValue('quantity');
}
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 06:44 AM
Hi Riya,
It worked.
Thanks for your response.
Regards,
Suvedha.