1

I know how to get FieldSet fields from within apex through describe. but I have the need to do it using javascript is this possible ? and if so how.

Thanks in advance Ronen

1

1 Answer 1

0

I gave this a shot using JSforce, let me know if this would be an acceptable approach in your case.

https://jsforce.github.io/

You can use login methods as shown here and get the access token,I went the VF route to avoid the login call and then get the access token approach.

https://jsforce.github.io/document/#connection

I used Metdata api option to read the field set object.

https://jsforce.github.io/document/#read-metadata

  <apex:page docType="html-5.0" showHeader="false">
  <apex:includeScript value="{!URLFOR($Resource.jsforce)}" /> <!-- Static Resource or Direct Link Below -->
  <script>
        var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}' });
        var fullNames = [ 'Account.prao6308__test_acc_fS' ];
        conn.metadata.read('FieldSet', fullNames, function(err, metadata) {


        if (err) { 
        console.error(err); 
        }

        console.log('Fieldset Label: '+ metadata.label);
        console.log('Fieldset Fullname: ' + metadata.fullName);
        for (var i=0; i < metadata.displayedFields.length; i++) {
            console.log("Field "+[i]+" inside field set: " + metadata.displayedFields[i].field);
        }

        });
  </script>
</apex:page>

Ouput:

enter image description here

1
  • Thank you very much , I didn't was familiar with this approach will give it a shot ! Thank you very much Nov 22, 2016 at 15:17

You must log in to answer this question.

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