0

I am able to get the "Type" fields Dependent field lists. But I can't find the child list for the particular parent drop-down.

Here is my code.

$finalApplicableOptions[$j][1] = array();
for($i=0;$i < count($result->fields); $i++){

        if($result->fields[$i]->name == "Type__c"){
            $sub = count($result->fields[$i]->picklistValues);
            for($j=0;$j<count($result->fields[$i]->picklistValues); $j++){
                $byteArr = $result->fields[$i]->picklistValues[$j]->validFor;

                $maparray = array();
                $map = "";
                foreach(str_split($byteArr) as $c)
                    $maparray [] = sprintf("%08b", ord($c));
                $map = implode("", $maparray );
                for ($k = 0; $k < strlen($map); $k++){
                    if($map{$k} == "1"){
                        $finalApplicableOptions[$j][1][] =  $result->fields[$i]->picklistValues[$j]->label;
                    }

                }
            }
        }
    }

Any one help me. Thanks in Advance!

0

This should help you - Just provide appropriate field names! https://iwritecrappycode.wordpress.com/2012/02/23/dependent-picklists-in-salesforce-without-metadata-api-or-visualforce/

14
  • Thanks For your help d_k. I tried this, got an error sforce.connection.sessionId: sf is undefined error occured. I included the three js files. Could you please help to fix this issue. Is there any way to done using PHP Code. – vimalraj Oct 19 '16 at 9:36
  • The JS will remain the same the syntax might differ a bit, Also are you using the latest files? – d_k Oct 19 '16 at 9:41
  • Yes I used the latest files. ajax/30.0/connection.js – vimalraj Oct 19 '16 at 9:44
  • Can you share the screenshot of the code and error as well? – d_k Oct 19 '16 at 9:48
  • I cant upload my Screenshots. Code: – vimalraj Oct 19 '16 at 10:00
0

It's possible to show the dependent picklist using PHP + JS. I have done this without Salesforce VF page.

Referred the above link( https://iwritecrappycode.wordpress.com/2012/02/23/dependent-picklists-in-salesforce-without-metadata-api-or-visualforce/ ).

I used the below steps:

1. Get the salesforce "Tasks" objects using "describeSObject" API via PHP.

2. Set PHP describe object result to "describeResults" in onready function. Removed the Included JS file and apex code.

3. I change the below code

From: var base64 = new sforce.Base64Binary(""); var decoded = base64.decode(validFor);

To: var decoded = atob(validFor);

4. Run the code. It works Good!!!

I hope it will help anyone.

Thanks!

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.