• ADARSH SINGH 17
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
In my requirement, I have to make multiple callouts with the Lightning component's server-side page load method.
So here I have created multiple HTTP request(i.e: 20) objects and bind each 3 in different continuation instances(20/3 => 7).
So in under this solution, I have to return a List<Continuation> from Apex to the client-side server as a response JSON. But when I do so, I received a blank object, instead of a JSON object.
 
// Action method
    @AuraEnabled(continuation=true cacheable=true)
    public static List<continuation> startRequest() {
        Map<String,String> headers=new Map<String,String>();
        String access_token = 'L90NMyHS2BcLSdtQ2iyJyr1MD5WdGjEt';
        headers.put('Content-Type','application/x-www-form-urlencoded');
        headers.put('Accept','application/json');
        headers.put('Authorization','Bearer ' + access_token);
        List<String> folderList = new List<String>{'108947290168', '108950868379'};
        List<continuation> lstCon = new List<continuation>();
        // Create continuation. Argument is timeout in seconds.
        for(String objFol : folderList){
            Continuation con = new Continuation(40);
            LONG_RUNNING_SERVICE_URL = LONG_RUNNING_SERVICE_URL+'objFol';
            // Set callback method
            con.continuationMethod='processResponse';
            // Set state
            
            // Create callout request
            HttpRequest req = new HttpRequest();
            req.setMethod('GET');
            req.setEndpoint(LONG_RUNNING_SERVICE_URL);
            system.debug('req--'+req);
            for(String ss : headers.keyset()){
                req.setHeader(ss,headers.get(ss));   
            }
            
            // Add callout request to continuation
            String strteemp = con.addHttpRequest(req);
            con.state = strteemp;
            lstCon.add(con);
        }
        // Return the continuations
        return lstCon;
    }
    
    // Callback method
    @AuraEnabled(cacheable=true)
    public static Object processResponse(List<String> labels, Object state) {
        // Get the response by using the unique label
        List<String> lstRes = new List<String>();
        for(String objStr : labels){
            HttpResponse response = Continuation.getResponse(objStr);
            // Set the result variable
            String result = response.getBody();
            lstRes.add(result);
        }
        return lstRes;
    }

**Note:** For POC purpose when I did the same flow for a single request(without iterating the for loop) with a single continuation object I got the response correctly from the @AuraEnabled apex method to the client-side(lightning controller.js). 
I have created custom fields under an object using the tooling API in an apex class. but by default, there is no Field Level Permission assigned to any specific profile for those fields. So can anyone please let me know, is there any way to assign FLS while creating fields using tooling API?

Thanks,
As we are working on Salesforce OpenCTI tool in a managed package. I just got stuck to invoking  Open CTI JavaScript library files(interaction.js and opencti_min.js) by using a default absolute URL.
As mentioned over Salesforce Document we use the following URL for different platform:

In Salesforce Classic: <script src="https://c.<yourInstance>.visual.force.com/support/api/46.0/interaction.js" type="text/javascript"></script>

In Lightning Experience:
<script src="https://c.<yourInstance>.visual.force.com/support/api/46.0/lightning/opencti_min.js" type="text/javascript"></script>

So, in above-mentioned URL what exact default <yourInstance> URL we have to use as absolute URL. So that we can use a single URL for all the customer's Salesforce instance.
We are done with all cumulusCI configuration set up, Now we are using MetaCI CLI v0.1.4 to run these same builds against your project automatically on Heroku. We are successfully deploying a new MetaCI site on Heroku using free dyno resources.
Now we are stuck in "Adding the Repository to MetaCI" section during metaCI implementation and we have the following execution with an exception:
 
Traceback (most recent call last):
File "/home/adarsh/Desktop/test-dir/venv/bin/metaci", line 11, in 
sys.exit(main())
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/metaci_cli/cli/config.py", line 150, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/metaci_cli/cli/commands/repo.py", line 126, in repo_list
res = api_client('repos', 'list', params=params)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/metaci_cli/metaci_api.py", line 27, in call
resp = self.client.action(self.document, args, **kwargs)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/coreapi/client.py", line 163, in action
link, link_ancestors = _lookup_link(document, keys)
File "/home/adarsh/Desktop/test-dir/venv/local/lib/python2.7/site-packages/coreapi/client.py", line 38, in _lookup_link
raise exceptions.LinkLookupError(msg % (index_string, repr(key).strip('u')))
coreapi.exceptions.LinkLookupError: Index ['repos']['list'] did not reference a link. Key 'repos' was not found.

Note: We are using 'metaci repo add' or 'metaci repo list' command to adding the repository to metaCI.

Thank you,
Adarsh Singh
Hi All, Can we validate and complete a trail-head challenge using Salesforce Dev hub Developer org?

Hi All,

 

I am new to Saleforce development. Please can any one guide me to sample apex code to create(add) custom fields to custom or standard objects dynamically using Salesforce Metadata API in my development org.

 

Thanks in advance.

  • June 29, 2011
  • Like
  • 0
I know i can do the following to get userid,firstname,lastname by using the static UserInfo class. But there is no method to get Email address. How do i get email address in a controller??

  String userId = UserInfo.getUserId();
String firstName = UserInfo.getFirstName();
String lastName = UserInfo.getLastName();

I know i can do {!$User.Email} but that would only be in the visualforce pages.
How do I get the email address of the logged in user in controller.