function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
christwin123christwin123 

Updating Fields Without Saving

Hi,

 

I need the Permanent address fields to be updated with Data Entered in the Present address field when s checkbox is Clicked .

 

Could someone Please guide me in getting this done.

 

Thanks you,

 

Regards,

Christwin

digamber.prasaddigamber.prasad

Hi,

 

If you want to achieve this on standard page layout, then only option is to use trigger. In trigger you will check if checkbox is true, you will copy address from present to permanent.

 

However, if you have visualforce page, then you can call an action from controller which will do this copy part. 

 

Let me know if you have any question.

 

Happy to help you!

Satish_SFDCSatish_SFDC
A Workflow can also help here, however, if there are any picklist fields, then a better option would be triggers.
A workflow can update a picklist field but only values can be the value before or after the current value.

Regards,
Satish Kumar
Satish_SFDCSatish_SFDC
Assuming the object is Contact
You can use the below code:

public trigger MyTrigger on Contact(before insert, before update){
for(Contact c: Trigger.new){
if(c.Checkbox__c ==true){
//Update all your fields here
c.permanent_Street__c = c.Present_Street__c;
c.permanent_City__c = c.present_City__c;
//etc
}
}
}

Hope this helps.


Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.
christwin123christwin123

Dear Prasad/Sathish,

 

Thank you for your reply.

 

I would like the Fields to be updated even before the Record is saved ..i.e before saving  itself I want the fields to be filled and shown with the Present Address Filled with the Permanent address once the Checkbox is clicked.

 

Could you please guide me in doing this.

 

Thankyou,

 

Regards,

Christwin

digamber.prasaddigamber.prasad

Hi,

 

That means you don't have standard page layout, but vf page. Please confirm!

christwin123christwin123

That Checkbox Field will be in the standard page layout of the Object with the Present and Permanent Address fields.

 

Thankyou,

 

Regards,

Christwin

digamber.prasaddigamber.prasad

Hi,

 

In that case, trigger will suffice your requirement. But you cann't have any UI related validation of this, like if you selected this checkbox, the permanent address field will not be disable. So most probably you have to create validation rule, checking if this check box is selected, user should not be able to enter different address in permanent address.

 

Let me know if you have any question.

 

Happy to help you!

christwin123christwin123

Hi,

 

Sorry I didnt convey correctly.

I want that present address field to be updated with the permanent address field data immediately after the checkbox is checked even before the save button is clicked.i.e while user is still filling in the form.

 

Thank you so much for your support,

 

Regards,

Christwin

digamber.prasaddigamber.prasad

Hi,

 

I am afraid that this can't be done with standard page layout.