You need to sign in to do that
Don't have an account?
Kasper Kristensen 3
Populating design picklist with fields based on object id
Hi.
I have a lightning component, with a design file that includes a two picklists. These picklists are currently being populated by referencing a class that extends "VisualEditor.DynamicPickList", using the datasource attribute on the design:attribute control. Like this : datasource="apex://ClassName.
This works fine, but i am getting all the fields specifically from the Account object right now, like this:
"Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.Account.fields.getMap();" and using that to populate the picklist.
What i would like to do, is to populate the picklist with all fields, based on what object the user is inserting the lightning component on. If the user inserts the lightning component on a Contact, it should list all Contact fields. If it is inserted on a Campaign object, it should list all the Campaign fields etc.
I am kinda stuck at how to to this.
I am supposed to be able to get the recordId, from the URL i guess. When i go into "Edit page" (where this should be used), i have a querystring in the URL called "pageId". And i should be able to get that through apex code. Something like this "ApexPages.CurrentPage().getparameters().get('id');".
But i can't get this to work. And i guess this has something to do with, that i am trying to do this in the "VisualEditor.DynamicPickList" extending class. But if someone could point me in the right direction, it would be awesome.
I just want to get the current object type in this extending class, that populates the picklists with field values. Simple as that.
I have a lightning component, with a design file that includes a two picklists. These picklists are currently being populated by referencing a class that extends "VisualEditor.DynamicPickList", using the datasource attribute on the design:attribute control. Like this : datasource="apex://ClassName.
This works fine, but i am getting all the fields specifically from the Account object right now, like this:
"Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.Account.fields.getMap();" and using that to populate the picklist.
What i would like to do, is to populate the picklist with all fields, based on what object the user is inserting the lightning component on. If the user inserts the lightning component on a Contact, it should list all Contact fields. If it is inserted on a Campaign object, it should list all the Campaign fields etc.
I am kinda stuck at how to to this.
I am supposed to be able to get the recordId, from the URL i guess. When i go into "Edit page" (where this should be used), i have a querystring in the URL called "pageId". And i should be able to get that through apex code. Something like this "ApexPages.CurrentPage().getparameters().get('id');".
But i can't get this to work. And i guess this has something to do with, that i am trying to do this in the "VisualEditor.DynamicPickList" extending class. But if someone could point me in the right direction, it would be awesome.
I just want to get the current object type in this extending class, that populates the picklists with field values. Simple as that.
I would also like to pass a parameter to my VisualEditor.DynamicPickList class or at least get the current object type.
Using url parameters similar to visualforce does not work, "apex://ClassName?id=yourId". (class does not exist error)
If this is indeed not possible we need to spin up an idea for SF!