开发者

In salesforce phptoolkit how to get dynamic dropdown values

  • I want to know how can i retrieve values for a dropdown that's dynamic based on other field. For example : How do i get values for "Sub Category" if its dependent on "Category" dropdown.开发者_开发百科

  • Also wanted to know how can i find all fields for "Case" which are required in order to submit new "Case". I am trying to do this using phptoolkit but i found no good documentation on it.


PHP toolkit in essence is a WSDL SOAP wrapper so anything applicable to salesforce API web servce applies to PHP toolkit.

The following is a procedure to solve your problems (I dont have a PHP sample):

  1. call describeSObject to retrieve information about the object
  2. Each field in describesObjectResult.Fields has three important properties for you, creatable, nillable and defaultedOnCreate. If createable and not nillable and not defaulted you must provide a value, this answers question #2
  3. if field type is picklist or multipcklist then fields' picklistValues contains a list of PicklistEntry elements. If picklist is dependent each entry contains a base64 encoded bitmap in validFor property. Each bit at position i is 0 or 1, corresponding to whether picklist entry is applicable for master picklist entry at position i.
  4. You have to decode the bitmap and use it to determine for which master picklist entries this particular entry can be used. Unfortuantely for now its the only way.

I can give you a sample in javascript of how I did it (lstCategories and lstSubcategories are arrays of PickListEntry), lstApplicableSubs is created having the list of subcategories for every category. This should give you an approach to decoding:

    var b64 = new sforce.Base64Binary("");
    lstApplicableSubs = new Array(lstCategories.length);
    for (var i = 0; i < lstApplicableSubs.length; i++) lstApplicableSubs[i] = new Array();
    for (i = 0; i < lstSubCategories.length; i++)
    {
        var map = b64.decode(lstSubCategories[i].validFor);
        for (var j = 0; j < lstCategories.length; j++)
        {
            var bits = map.charCodeAt(j >> 3);
            if ((bits & (0x80 >> (j & 0x07))) != 0) lstApplicableSubs[j].push(lstSubCategories[i]);
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜