I have a custom VF page embedded on my Opportunity object. The button populates a custom picklist field with one of the picklist values through a custom label. However, when I have the "Restrict picklist to the values Defined in the Value Set" option clicked in the custom field setup, the button does not populate the field. When I uncheck that option, it populates the field with the exact value that's in the picklist. Does anyone know what this happens or how to fix it?
Picklist Values: Final EVP DC
Custom Label Values: Final EVP DC
VF Page:
<apex:page standardController="Opportunity" >
<script src="/soap/ajax/26.0/connection.js"/>
<script src="/soap/ajax/26.0/apex.js"/>
<script src="/support/console/27.0/integration.js"/>
<script type="text/javascript">
sforce.connection.sessionId = "{!GETSESSIONID()}";
function evp()
{
var opp = new sforce.SObject("Opportunity");
opp.id = "{!Opportunity.Id}";
var result = sforce.connection.query("SELECT Id FROM ProcessInstanceWorkitem WHERE processInstance.TargetObjectId='{!Opportunity.Id}'");
var approvals = result.getArray("records");
opp.AppRejStat__c = "{!$Label.App_BtnEVP}";
var approvalID = approvals[0].Id;
window.open('/p/process/ProcessInstanceWorkitemWizardStageManager?id='+approvalID);
sforce.connection.update([opp]);
return this;
};
</script>
<apex:form >
<div style="text-align: left"><p/>
<apex:commandButton Value="Approve/Reject - Send To EVP" onClick="evp();"
rendered="{!IF(opportunity.Approval_Status__c = $Label.App_MD,TRUE,FALSE)}"/>
</div>
</apex:form>
</apex:page>