Append field values into a new field everytime another field is updated by a user

Kiara3
Kilo Contributor

Hello Experts,

Requesting your inputs on below requirement:

I am working on customization of a Form. Have added couple of fields on it. 

Fields to consider in this requirement are :

> Due Date

> Due Date change counter

> Due Date Change Category

> State

Everytime a user updates "Due Date" field, the "Due Date change counter" is increased by 1. This is already working fine.

My requirement is to add the values of these fields into a new Read-Only Field everytime "Due Date" is updated

> Due Date : the Previous due date and the new one

> Due Date change counter : the current counter after updating

> Due Date Change Category : User can change this field all the time. So main idea was to capture the Category for all the due date updates done so far.

> State : the current state

I want these records to be Appended everytime a user updates "Due Date".

Something like below:

Previous Due Date : 25-03-2022

New Due Date : 30-03-22

Due Date change counter : 1

Due Date Change Category : Cat1

State : Review

 

Previous Due Date : 30-03-2022

New Due Date : 10-04-22

Due Date change counter : 2

Due Date Change Category : Cat5

State : Work In Progress

Could you please suggest an appropriate way forward.

 

Thanks.

2 REPLIES 2

Muhammad Khan
Mega Sage
Mega Sage

Hi Kiara,

 

Following steps might fulfill your requirement;

1. Create a a Journal  field on your table. Make sure that you have not made it as Read Only.

2. Create an onLoad UI Policy on your table and make the above Journal field as Read Only = true.

For reference observe the following images;

find_real_file.png

find_real_file.png

3. Create an onChange() Client Script on your table and use the following script. Make sure to use your field names properly;

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
	g_form.setReadOnly('u_journal_field', false);
	g_form.setValue('u_journal_field', 'Previous Due Date: ' + oldValue + '\nNew Due Date: ' + newValue + '\nDue Date Change Counter: ' + g_form.getValue('u_time_field') + '\nDue Date Change Category: ' + g_form.getValue('u_date_time_field') + '\nState: ' + g_form.getValue('u_duration_field'));
	g_form.setReadOnly('u_journal_field', true);
   
}

For reference observe the following image;

find_real_file.png

 

I have used dummy fields to test your requirement and the output will look like this;

find_real_file.png

 

 

Hopefully this will fulfill your requirement.

Hi Muhammad,

 

ThankYou for the detailed guidance. I will try this and check if it's working for my use case 🙂