0

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>
7
  • Is your value in custom label and the one in picklist exactly same?
    – Jayant Das
    Commented Oct 17, 2018 at 19:56
  • Yes, I literally copied one from the other.
    – J. Neilan
    Commented Oct 17, 2018 at 19:57
  • 2
    Sometimes that can cause issues too. Just verify if you have trailing spaces in one or the other. Because based on what you are mentioning, if you remove the restrict options in picklist and it works, I doubt if the values have something very minor difference such as a space to notice.
    – Jayant Das
    Commented Oct 17, 2018 at 20:00
  • Thanks. I did check the spaces and that's not the issue. I don't know what it is, the 2 values are exactly the same!
    – J. Neilan
    Commented Oct 17, 2018 at 20:14
  • 1
    No difference between the Label and API Value for that picklist entry?
    – David Reed
    Commented Oct 17, 2018 at 20:28

1 Answer 1

0

Each picklist value has a display label and API name. After Spring 17 we can change the picklist label without changing the API name. So please make sure api name and label of picklist value is same. Like that:

enter image description here

1
  • Ah, thanks so much. That did it. I am used to API names needing underscore characters and not allowing spaces.
    – J. Neilan
    Commented Oct 18, 2018 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .