• Jackie Walker
  • NEWBIE
  • 10 Points
  • Member since 2017
  • Demo Engineer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

Hi everyone,


I've been testing out a component where one can programmatically create a field in the user object. It's being used to allow a user to check a few boxes that'll filter coimponents in pages (using component filtering) that is unique to that user.

With this test I've met an annoying problem. If I manually create the field, it's all good because we get to decide the field level access. But when I create it programmatically it comes with zero access to any users.

The way I'm creating the field is:

HttpRequest requestinside = new HttpRequest();
            requestinside.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
            requestinside.setHeader('Content-Type', 'application/json');
            requestinside.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v26.0/tooling/sobjects/CustomField/');
            requestinside.setMethod('POST');
            String fieldDef = '{"Metadata" : ';
            String metadef = '"type" : "Checkbox","description" : "'+fielddescription+'","defaultValue":"true", "inlineHelpText" : "","precision" : null,"label" : "'+fieldlabel+'","required" : false';
            fieldDef += '{'+metadef+'},';
            fieldDef += '"FullName" : "'+objectapiname+'.'+fieldapiname+'"}';
            system.debug(fieldDef);
            requestinside.setBody(fieldDef);
            Http http = new Http();
            HTTPResponse res = http.send(requestinside);
            System.debug(res.getBody());

 

Basically using the API. But I've been experimenting with the MetadataService class to try to add field permissions to a permission set when the field is created. This isn't working though and the documentation for this class is very slim.

Does anyone know of a way I could either add CRUD permissions for the new field to a permission set or a profile programmatically right after the field is created?

I've been having a problem with the autocheck here...

"The 'Key Accounts' report does appear to be grouped by Account Name."

But my report is grouped by Account name. I also tried to group by both the name and Opp owner (from the other challenge) and it didn't work either...

Hi everyone,


I've been testing out a component where one can programmatically create a field in the user object. It's being used to allow a user to check a few boxes that'll filter coimponents in pages (using component filtering) that is unique to that user.

With this test I've met an annoying problem. If I manually create the field, it's all good because we get to decide the field level access. But when I create it programmatically it comes with zero access to any users.

The way I'm creating the field is:

HttpRequest requestinside = new HttpRequest();
            requestinside.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
            requestinside.setHeader('Content-Type', 'application/json');
            requestinside.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v26.0/tooling/sobjects/CustomField/');
            requestinside.setMethod('POST');
            String fieldDef = '{"Metadata" : ';
            String metadef = '"type" : "Checkbox","description" : "'+fielddescription+'","defaultValue":"true", "inlineHelpText" : "","precision" : null,"label" : "'+fieldlabel+'","required" : false';
            fieldDef += '{'+metadef+'},';
            fieldDef += '"FullName" : "'+objectapiname+'.'+fieldapiname+'"}';
            system.debug(fieldDef);
            requestinside.setBody(fieldDef);
            Http http = new Http();
            HTTPResponse res = http.send(requestinside);
            System.debug(res.getBody());

 

Basically using the API. But I've been experimenting with the MetadataService class to try to add field permissions to a permission set when the field is created. This isn't working though and the documentation for this class is very slim.

Does anyone know of a way I could either add CRUD permissions for the new field to a permission set or a profile programmatically right after the field is created?

I've been having a problem with the autocheck here...

"The 'Key Accounts' report does appear to be grouped by Account Name."

But my report is grouped by Account name. I also tried to group by both the name and Opp owner (from the other challenge) and it didn't work either...

Challenge Not yet complete... here's what's wrong: 
The Campaign object has does not appear to have an Account lookup field called "Chapter". 
Note: you may run into errors if you've skipped previous steps.
This is the error I am getting when trying to verify my step.

This is the link to the trailhead question. 

I did all the steps as it said but I can't get it to pass.

These fields I made are placed in "Campaign" object that I created (there was no existing Campaign object in my env
Above are the fields I created in the "Campaign" custom object. I had to create it because no existing object.

User-added image
As you can see, it does have the lookup field to account.

So why am I still getting the error?
I'm pretty sure I have created a hybrid mobile app - but I still get this message 'Challenge Not yet complete... here's what's wrong: You haven't run and logged in from the 'TrailheadHybridTest' app.' I created a new Dev org and logged in to the app OK but Trailhead won't let me pass this challenge. 
When you create a lightning component and put that on an opportunity record home page (oppty detail page), it is pilot functionality right now. 
I created a lightning component that draws some graphics and it is dependent on some felds on the oppty and some related records (task & events). So if I change the close date I need to refresh my component, but also if a new task/event is added from the oppty page I need to redraw the component.

What event do you need to listen to in order to detect a change on any field on the oppty itself? Or do I need to do something else?

Any ideas?