• Ayush Shukla
  • NEWBIE
  • 25 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hi Friends
I have a custom object with 4 properties, First, Second, Third and Forth
Now I also have a Map<string, string> Values which has data as 
<First, 10>
<Second,20>
<Third, 30>
<Forth, 40>

Now I want a way to iterate over all the Keys in MAP and assign the value of corrosponding property of the object from value from MAP.
for(string keyValue : Map.GetKeys())
{
Object.Proeprty_Name = Map.Get(keyValue);
}

I can also do it other way by iterating over the properties of the object (by getting them using getMap()) and then see if the collection.ContainKey with that property Name.

Its kind of reflection in .net.

please guide on how to achieve it
When user update a record(update will done by community user).Same record can view by multiple internal  users. whoever is viewing the that record i need to show alert or toaster to those user.

any suggestons.

Thanks
Vamsikrishna B.
I'm using .Net to try and create a simple client app to connect to Salesforce for a demo application.   Steps I've completed:

1) In App Manager, created my Connect App.   Have Enable for Device Flow checked.  Generated my Initial Access Token, my Consumer Key, and my Consumer Secret.

2) Here's my .Net code:

            HttpClient authClient = new HttpClient();

            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11;

            Dictionary<string, string> contDictionary = new Dictionary<string, string>();
            contDictionary.Add("grant_type", "password");
            contDictionary.Add("client_id", consumerKey);
            contDictionary.Add("client_secret", consumerSecret);
            contDictionary.Add("username", userName);
            contDictionary.Add("password", pwd + token);


            HttpContent content = new FormUrlEncodedContent(contDictionary);
            HttpResponseMessage message = await authClient.PostAsync("https://login.salesforce.com/services/oauth2/token", content);

            string responseString = await message.Content.ReadAsStringAsync();

            var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseString);
            string authToken = values["access_token"];
            string instanceUrl = values["instance_url"];

When the PostAsync is called, I get a "Bad Request". 

Any help would be greatly appreciated.
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). 
Hi Friends
I have a custom object with 4 properties, First, Second, Third and Forth
Now I also have a Map<string, string> Values which has data as 
<First, 10>
<Second,20>
<Third, 30>
<Forth, 40>

Now I want a way to iterate over all the Keys in MAP and assign the value of corrosponding property of the object from value from MAP.
for(string keyValue : Map.GetKeys())
{
Object.Proeprty_Name = Map.Get(keyValue);
}

I can also do it other way by iterating over the properties of the object (by getting them using getMap()) and then see if the collection.ContainKey with that property Name.

Its kind of reflection in .net.

please guide on how to achieve it