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
AbAb 

Updating the text and text area when the pick list values changes

Hello,

I have a custom object like below:
CustomObject1__c
   CustomField1__c (Picklist, values: Val1, Val2, Val3)
   CustomField2__c (Text: 100 char)
   CustomField3__c (Tex Area)

I have a visualforce page whcih displays the 3 input fields above like below
 
<apex:inputField value="{!CustomObject1__c.CustomField1__c }" />
<apex:inputField value="{!CustomObject1__c.CustomField2__c }" />
<apex:inputField value="{!CustomObject1__c.CustomField3__c}" />
Use case
1) When the CustomField1__c is changed to Val1, i want the below things to happen
> the CustomField2__c is updated to "recordtypename+username+val1"
>the CustomField3__c is updated to
 "the user name is username, record type name isrecordtypename and the value selected is Val1
Date:
Time:
 "
Thanks for suggestions !

 
Best Answer chosen by Ab
Sumit Kumar Singh 9Sumit Kumar Singh 9
Hi Sandrine, 

There are 2 ways to accomplish it. 
1) You can use javescript.
2) You can use Action support



Thanks, 
Sumit Kumar Singh

All Answers

brahmaji tammanabrahmaji tammana
Hi Sandrine,

Try below code:
 
trigger RecordType on Project__c (before insert, before update) {    
    public String spold;
    public String spnew;
    for(Project__c p :Trigger.New){
        spnew = p.Priority__c;
        for(Project__c pold : Trigger.old){
            spold = pold.Priority__c;
        }
        p.Audit_Field__c = 'Priority field is updated from '+spold+' to '+spnew+' by '+UserInfo.getUserEmail() + ' on '+System.now() + '\n' +p.Audit_Field__c;
        //Audit Field is my custom field where the histroy has to be tracked
        //In your case, CustomField2__C and CustomField3__C will be Audit fields
    }

}

Let me know it worked or not.

Thanks
Brahma
Sagar LakhaniSagar Lakhani

Hi Sandrine,

 

You have to simply create a workflow rules on your custom object to make this field update based on Picklist values.

Like

Evaluation Criteria  : Evaluate the rule when a record is created, and every time it's edited

Rule Criteria : CustomField1__c  Equals to Val1

Then in Immediate Workflow Actions add field update to update field which you want update when Picklist value is 'Val1'.

 

Thanks,

Sagar Lakhani.

 

AbAb
Hello,

Thank you for replies,
but i dont think that can serve my use case,
 
<apex:inputField value="{!CustomObject1__c.CustomField1__c }" />
<apex:inputField value="{!CustomObject1__c.CustomField2__c }" />
<apex:inputField value="{!CustomObject1__c.CustomField3__c}" />

i have above input fields on the same VF page, if first value (which is picklist) is changed then the two other fields which are text and text area changes.

I think what i am looking for is action fucntion.
Sumit Kumar Singh 9Sumit Kumar Singh 9
Hi Sandrine, 

There are 2 ways to accomplish it. 
1) You can use javescript.
2) You can use Action support



Thanks, 
Sumit Kumar Singh
This was selected as the best answer