2

I'm using the live chat in salesforce, however I want to use a picklist from the account object. To add fields in the prechat page I have some fields using the following logic.

<div class="row marginbottom10">
       <div class="col-xs-4">Company name:</div><div class="col-xs-8">* <input type="text" name="liveagent.prechat.contactAccount" style="width:95%;"/></div>
       <div class="col-xs-12 errorText" id="errAccount">Company name must be entered</div>
</div>

However to use a picklist from the account i would have to use the apex inputfield. I have tried this, since name attribute is not supported. But it is not passed through

<apex:inputField html-name="liveagent.prechat.accountCountry" value="{!Account.Country_List__c}"/>

Do any of you know how to get the name attribute on the input field? It is needed in livechat.

Thank you for your help.

Best regards, Christian.

6
  • This is mainly so that I do not have to maintain two Country picklists. Mar 3 '17 at 13:51
  • More info can be found here: developer.salesforce.com/docs/atlas.en-us.live_agent_dev.meta/… Mar 3 '17 at 13:51
  • Visualforce sets the name based on the id of the field. You're using the html passthrough correctly...it just doesn't work for the name field. You couldn't set the ID, though, because Visualforce won't let you use ':' in an ID on a Visualforce component. Are you able to make the <apex:inputField> hidden and use javascript to pull values from that and add them to a visible regular input field? Mar 3 '17 at 14:01
  • That is also where I am at was just think about showing that field and using JavaScript to copy the value over. It would have been nice to be able to either use <apex:inputField> or being able to set the name. I mean it is all salesforce made functionality it should work together. I was also looking into doing something like this: {!$ObjectType.Account.Fields.Country_list__c.picklistValues} but picklist does not allow that only label even though this says different: developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/… Mar 3 '17 at 14:15
  • For bootstrap I avoid using inputField's component, use plain HTML components and pull picklist values from controller
    – Raul
    Mar 3 '17 at 14:15
2

I have found that to assign the name attribute you assign the Id attribute. However in this case this did not Work because the name I had to set contained a ':' which was not supported. I ended up Building a controller for the page. It looks like this:

public without sharing class MccPreChatPageController {

public List<String> countryPickListValuesList {get; set;}

public list<String> getCountryPicklistValues(){
    List<Schema.PicklistEntry> ple = Account.Fields.Country_list__c.getDescribe().getPicklistValues();
    list<String> countryPickListValuesList = new list<String>();
    for(Schema.PicklistEntry countryName : ple){
        if(countryName.isActive()){
            countryPickListValuesList.add(countryName.getLabel());

        }
    }
    return countryPickListValuesList;
}

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.