githubbob42 / mingle2github2

0 stars 1 forks source link

Create the APEX class to return field sets #2265

Open githubbob42 opened 5 years ago

githubbob42 commented 5 years ago

Mingle Card: 2513 This should be similar to the GetUtilityUserInfo class but it should return ticket item field sets. Is there a way to add parameters to this call?

@RestResource(urlMapping='/GetUtilityUserInfo/\*')

global with sharing class GetUtilityUserInfo{

    @HttpGet

    global static String doPost() {

        string userinfo = UtilityUserInfo.CurrentUserInfo();

        return userinfo;

    }

}

(http://salesforce.stackexchange.com/questions/38585/is-it-possible-to-get-an-objects-fieldsets-with-the-rest-api)

As for parameters, we should be able to pass them as part of the URL. e.g.

We'll need to do a little research on how to extract that info from within the RestResource...

I think that these will answer most/all of our questions:

@RestResource(urlMapping='/getFieldSets/\*')

global with sharing class FieldSetSvc{

    @HttpGet

    global static List<FieldSet> getFieldSets() {

       ...

    }

}

The salesforce restExplorer can be used to test the class:

https://workbench.developerforce.com/restExplorer.php

/services/apexrest/getFieldSets?sObject=Ticket__c

I created a fieldset on the ticket object. This was the result:

Raw Response

HTTP/1.1 200 OK

Date: Tue, 15 Jul 2014 16:10:29 GMT

Content-Type: application/json;charset=UTF-8

Content-Encoding: gzip

Transfer-Encoding: chunked

\[ {

  "fieldsetname" : "test",

  "fields" : \[ {

    "isrequired" : false,

    "isDBrequired" : false,

    "fieldtype" : "PICKLIST",

    "fieldpath" : "Category\_\_c",

    "fieldname" : null,

    "fieldlabel" : "Category"

  }, {

    "isrequired" : false,

    "isDBrequired" : false,

    "fieldtype" : "STRING",

    "fieldpath" : "Contract\_\_c",

    "fieldname" : null,

    "fieldlabel" : "Contract"

  }, {

    "isrequired" : false,

    "isDBrequired" : true,

    "fieldtype" : "PICKLIST",

    "fieldpath" : "CurrencyIsoCode",

    "fieldname" : null,

    "fieldlabel" : "Currency ISO Code"

  }, {

    "isrequired" : false,

    "isDBrequired" : true,

    "fieldtype" : "REFERENCE",

    "fieldpath" : "Job\_\_c",

    "fieldname" : null,

    "fieldlabel" : "Job"

  } \]

} \]
githubbob42 commented 5 years ago

Story: #2264 Provide access to field sets to Mobile (Mingle)