You need to sign in to do that
Don't have an account?
Dynamically changing value of custom picklist field
I have a picklist field with values 'Yes', 'No'
On the web portal if a user uploads a document, I want the picklist value to change from 'No' to 'yes'.
If the value is already 'Yes', keep it as 'Yes'.
Can someone please shed light on how I can achieve this?
Thanks in advance.
I suppose you have a controller to the vf page. In the upload button action method in controller rite this condition
This is as per my understanding of the issue. if there is more info you want specifically can you give more detailed description of the case and please put the controller code and VF code.
All Answers
I suppose you have a controller to the vf page. In the upload button action method in controller rite this condition
This is as per my understanding of the issue. if there is more info you want specifically can you give more detailed description of the case and please put the controller code and VF code.
Yeah,
You would have to check the Blob value is null or not null . On the basis of that you can change the picklist value to Yes in your apex code .
Thanks,
Kirtesh
If you are not using the VF page then you would have to write trigger and need to check the documents uploaded and then can take decesion..
Please provide more detailsif you are not ok with solns.
Thanks.
Kirtesh
CodeFinder, Thank you very much ! Yes you are right I have a controller to the vf page. I shall try this and let you know.
Thanks for your reply Kirtesh. I will try a solution posted by CodeFinder which is similar to your solution. I will try it and let you know. Much appreciated!!
I am sure the value must be changing but the problem is its not getting updated to the database. You have to update the Sobject after the change in the picklist.
For this code
I am sure the value must be changing but the problem is its not getting updated to the database. You have to update the Sobject after the change in the picklist.
CodeFinder, thanks heaps!!! You are right I was't updating the Supplier object. I added update Supplier and that solved my problem.
if (this.Supplier.Is_your_company_certified_as_Diverse__c != 'Yes'){
this.Supplier.Is_your_company_certified_as_Diverse__c = 'Yes';
update Supplier;
}
Thanks, once again.