Get field sets of an Object

  • 1
  • Idea
  • Updated 4 years ago
  • Under Consideration
Hi,

I have defined field sets in a object, I use them in apex to on record creation get fields from other related objects and copy them into this object: 



Can I get the Field sets of this object in skuid?

I'm trying to do a "reset record" to get all this fields and copy them again, replacing all the modifications to the record that the users have done of the original data.

I have done it without the fieldsets, something like:

$.each( selectedItems,    function( i, item )
    {
        var row = item.row;
        rowsToUpdate[ row.Id ] = { 
Total_Install_Charges_BC__c: row.Sales_Product__r.Total_Install_Charges_BC__c,
Total_Monthly_Charges_BC__c: row.Sales_Product__r.Total_Monthly_Charges_BC__c, [...] (rest of all the fields to copy, more than 60 fields)
};
    });

It's working, the only problem is maintain the fields, every time I have to add or remove a field i have to edit the fieldset, go to the skuid snippet and remove/add the field form the rowsToUpdate.

So, If I can get the fieldsets from salesforce It will be easier to maintain.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
There's probably a way to get the filed name and value from the "row.Sales_Product__r" object. So you could probably do something like this:

$.each( selectedItems, function(i,item){    var row = item.row;
var myVar = [];
//there should be a way to get at the field names, maybe 
$.each(row.Sales_Product__r, function(j,field)){
//figure out how to get the field name and value from the loop var
myVar[field.name] = field.value;
}
    rowsToUpdate[row.Id] = myVar;
});
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Yes, but not all the fields of the "Sales product" are needed
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
Hi Pablo,

Currently, we do not give you access to field sets from Skuid out of the box.  You would have to write an Apex remote action and use Javascript Remoting to get this information.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
I have recreated the Field sets as Javascript arrays, It's easier to maintain...
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Field sets are not currently supported for display within components.  But your use case is very interesting. It does seem that the API should provide access to all the fields in a field set.  This makes sense.  We will add it to the list for consideration. 
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Thanks rob.