• Swamy P
  • NEWBIE
  • 90 Points
  • Member since 2012
  • SSE
  • Accenture

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 75
    Questions
  • 44
    Replies
Hello Team,

I wanted to know how can we integrate voice with the salesforce1, for example if a say "Test Lead" in salesforce1 vf page, it should recognize and show the corresponding leads in a vf page.
This is my basic scenario, so here i wanted to know how can we integrate with voice with the salesforce1/classic/Lightning.

So please do let me know if anybody has any idea in this forum. 

Thanks,
Swamy P R N.
Hello Team,

We were facing an issue on converting minutes into hours and days. The requirement is like when we have 1520minutes, result must show like 1day1hr20minutes
Usually to convert minutes to hours we will divide by 60. Can anyone help me on showing this result by apex?

Thanks in advance!!
Hello Team,

I was trying to share the opportunity record using apex(PartnerNetworkRecordConnection). So for that, i'm adding following snippet of code in test class:
     Account a = new Account(Name='Acme1', BillingCity='San Francisco');
     insert a;
     
        Opportunity op1 = new Opportunity(Name='ChildTest123',Accountid=a.Id, StageName='2 - Qualified', CloseDate=System.today() - 50,Expected_Product__c=10.0,error_description__c='error',DealID__c='1',Opportunity_Status__c='Active');
  insert op1;
      
       PartnerNetworkConnection networkConn =[select Id from PartnerNetworkConnection where ConnectionName = 'Services One' and ConnectionStatus = 'Accepted']; // and AccountId=:a.Id 

       PartnerNetworkRecordConnection newConnection = new PartnerNetworkRecordConnection(ConnectionId = networkConn.Id, LocalRecordId = op1.Id, ParentRecordId = op1.AccountId);
       insert newConnection; 


When i ran the test class, it is throwing the below error. Can anyone suggest us to resolve the issue.
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation: []

Thanks,
Swamy P R N
Hello Team,
I have a functionality to show the accounts based on the search result, here is my code. 
APP:
<aura:application >
    <c:SearchBarCmp />
    <c:AccountListCmp />
</aura:application>

AccountList Component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="Swamy_2011.AccountsWithContactsSearchController">
    <aura:attribute name="accnts" type="Account[]"/>
    <aura:handler event="Swamy_2011:SearchKeyChange" action="{!c.SearchKeyChange}"/>
    
    <aura:iteration items="{!v.accnts}" var="acc">
        <p>{!acc.Name}</p>
    </aura:iteration>
</aura:component>

AccListCmpJS:
({
    SearchKeyChange : function(component, event, helper) {
        var searchKey = event.getParam("searchKey");
        var action = component.get("c.accByIds");
        action.setParams({
          "searchKey": searchKey
        });
        action.setCallback(this, function(a) {
            component.set("v.accnts", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})

Class:
public class AccountsWithContactsSearchController {
    
    @AuraEnabled
    Public static List<Account> accByIds(string accId){
        List<Account> acc = new List<Account>();
            String name =  string.escapesinglequotes(accId) + '%';
            acc = [Select Id, Name, Type from Account where Name Like:name];
        return acc;
    }
}

Same logic working for Contact records, Suggest me where i missed the code for Account, i hope everything perfect otherthan CSS.

Thanks,
Swamy P R N.
  • September 28, 2017
  • Like
  • 0
Hello Team,

As salesforce providing free developer edition with the data storage limit 5MB, is there any data storage limit specific to any of the object? Like Account should not exceed 0.5MB and Contacts should not exceed 1MB, something like that.
Or is that storage for whole organization?

I believe there is no limit to individual object but i need confirmation.

Thanks,
Swamy P R N.
  • September 20, 2017
  • Like
  • 0
Hello Everyone,

I would kike to know few of the answers to the below questions, 
1. There are two fields, if the user populate two field values if we combine those values uniqueness should be maintained, how to achieve this without coding?

2.There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object, if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?

3. How many maximum groupings we can do for summary, matrix and join reports?

Thanks in advance!!
Currently, we have email to case set up in UAT/PROD for salesforce.
When a user emails to abc@xyz.com, salesforce is configured to create a case automatically.
The problem arises when someone replies to the original email. It creates a new case.
Can anyone please investigate, if they reply to the original email it should not create a new case? Emails should append to the original case.

Thank you very much in advance!!
Hello Everyone,

I have created visualforce email template and tagged to approval process which will get trigger to Approver when some one request for approval.
 
When Approver tries to approve/reject through the email he/she received, approval response is not changing accordingly in salesforce.

Can some one please suggest what might be the problem here. Is the problem with visualforce template or any ?

Thanks in advance!!!

 
Hello Team,

I just wanted to know that when we add Recursion for a TriggerHandler classes, is that logic will be executed after the first record?
I mean, If we Upsert 100 records using Data Loader.. Is the logic will execute for all of the 100 records or because of recursion is it going to stop the execution of logic after 1st record?

Please provide your answers ASAP.
Hello Everyone,

I was trying to Convert String to a SobjectField API Name but unfortunately not able to convert it, here is my code. 
     Map <String, Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get('O_Product__c').getDescribe().fields.getMap();
              Map<String,String> POIMap= new Map<String,String>();  -->Here In this map I'm capturing Field Label and Name
             for(Schema.SObjectField sfield : fieldMap.Values())
             {
              schema.describefieldresult dfield = sfield.getDescribe();         
              POIMap.put(dfield.getLabel(),dfield.getname());
             }

String fldApi = POIMap.get('Value for '+newLead.CurrencyIsoCode); --> Here I want to convert "fldApi" into SobjectField API Name
How can we Convert it String into Field API Name?
Hello Everyone,

I'm working on Parsing CSV File by "Apex". I'm facing an error "List index out of bounds: 1", I understand the error that I'm accessing which Is not having any value but I'm unable to get the solution. Below is my requirement and code which I'm trying to parse, please check it and update me where I can change.

Requirement: From ExcelColumn1 & Column2 needs to be Mapped for different Rows, like that Column5 & Column8 needs to be Mapped.

for(list<string> line:parsedCSV){                                  
       if(line[1]!=''&& line[1]!=null && line[2]!='' && line[2]!=null){
           lineMap.put(line[1],line[2]); -->Error Line - Sometimes error appearing here
       } 
       System.Debug(' lineMap..'+ lineMap);
       if(line[1]!='' && line[5]!='' && line[1]!=null && line[5]!=null){
           lineMap.put(line[1],line[5]);  -->Error Line - Sometimes error appearing here
       }       
}     
In "parsedCSV" list I'm getting all of the ROWS, Also in debug logs I'm able to see some of the values which are captured in LineMap.

As i know that we can fix this issue without passing hard-coded numbers in Arrays but as per the requirement I've to implement it in this way, If anyone knows anyother solution, Please update me. Thanks in Advance!!!!!

Any Suggestion will be Appreciated.
Hello Team,

I'm adding Case Team Members based on the Case object Field Comparision, Now if any of the user removing from CaseTeam object I wanted to Track that.

If any of the user removed from my caseteam, I wanted to create a record in Custom object with that Case and the respective removed User.

How can we achieve these kind of Situations? Your help really appreciated because these are OOB's.
I was trying to call Docusign Webservices from my Sandbox but i'm getting the below error, I tried with Admin credentials but no result.
Error:
 System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: This User lacks sufficient permissions. User does not have the permision to the CreateEnvelopeFromTemplates method faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx

For further details, please refer the below image.
User-added image
Hello Everyone,

Do we have any mechanism to capture Mail response for the Mail which we sent from Salesforce?

Example: I sent an email to customer from Contact record, if my customer replies back on the same Email-ID, than I've to capture that in the Same Contact Record. 

Please share your Ideas/Solutions.

Thanks in advance...
Hello Everyone,

I was working on Parsing Excel File by Apex but unfortunately i was not able to get specific row and specific column value. By using Parsing, i was able to fetch  all of the columns but i wanted to get specific row also. Below is the code which I've used for Columns:
         string  csvAsString = csvFileBody.toString();
           String[] csvFileLines = csvAsString.split('\n');             
           for(Integer i=1;i<csvFileLines.size();i++){
               Contact accObj = new Contact() ;
               string[] csvRecordData = csvFileLines[i].split(','); //In this i was able to fetch Columns, from this i wanted to get Row Value
           }    
 Help me on getting the specific Row&Column value from an excel.
Thanks in advance!!!              
Hello Everyone,

I wanted to show a Grand Total Value by adding all of the Total Values which is appearing in the below image. All these are ROWS are added dynamically.
User-added image

I've already implemented some of the code but it is not showing Correct/Exact values. Please provide your valuable solutions.
Hello Everyone,

I just wanted to know whether current date is in last 10 business working days of an Quarter or not, So how can i get it? 

We have a Quarter query, with that we can fetch End Date of the Quarter. So finally how can i check whether current date is in last 10 business working days of an Quarter or not?

Your help will be really appreciated!!!
Hello Everyone,

So far i'm sending data in email by html code using APEX. Now end user want to have an option to export data into excel from the HTML email.

How can we provide an option in the email to generate data in excel format? please provide your valuable thoughts.

Thanks in advance!!!
Hello everyone,

i'm able to see "New button" in all of the lookup buttons but i want to hide that "New button" for some of the Lookup's(some of the objects).

How can i a cheive this? Suggest me..

Thanks in advance!!!
Hi all,

Please help me find out solution for sending workflow email alert.
My Deliverability access level is 'all emails',  still it is not able to send email alert.
I have tried test deliverability - it is not sending 52 emails to the intended email address.

Thanks in advance. 
Hello Users,

I have to insert 50000 contacts into my Contact object.But we are having account lookup in contact object, i have only account name in the excel sheet.

So in seperate excel sheet i just exported id, name from account. Now i cannot compare manually the this name in another excel sheet for association of record id. By using some formulaes we can achieve this functionality.

Can anyone suggest me the solution to place the id's instead of name. 

Thanks in advance!!
Hello Team,

We were facing an issue on converting minutes into hours and days. The requirement is like when we have 1520minutes, result must show like 1day1hr20minutes
Usually to convert minutes to hours we will divide by 60. Can anyone help me on showing this result by apex?

Thanks in advance!!
Hello Everyone,

I have created visualforce email template and tagged to approval process which will get trigger to Approver when some one request for approval.
 
When Approver tries to approve/reject through the email he/she received, approval response is not changing accordingly in salesforce.

Can some one please suggest what might be the problem here. Is the problem with visualforce template or any ?

Thanks in advance!!!

 
I was trying to call Docusign Webservices from my Sandbox but i'm getting the below error, I tried with Admin credentials but no result.
Error:
 System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: This User lacks sufficient permissions. User does not have the permision to the CreateEnvelopeFromTemplates method faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx

For further details, please refer the below image.
User-added image
Hello Everyone,

I wanted to show a Grand Total Value by adding all of the Total Values which is appearing in the below image. All these are ROWS are added dynamically.
User-added image

I've already implemented some of the code but it is not showing Correct/Exact values. Please provide your valuable solutions.
Hello Everyone,

I just wanted to know whether current date is in last 10 business working days of an Quarter or not, So how can i get it? 

We have a Quarter query, with that we can fetch End Date of the Quarter. So finally how can i check whether current date is in last 10 business working days of an Quarter or not?

Your help will be really appreciated!!!
Hello everyone,

i'm able to see "New button" in all of the lookup buttons but i want to hide that "New button" for some of the Lookup's(some of the objects).

How can i a cheive this? Suggest me..

Thanks in advance!!!
Hello Folks,

In Apex Class i'm using dynamic SOQL, below is my code:
 string soql='select id,name,Area__c,City__c,Address__c from User_Detail__c where name!=null';
        if(usr.Area__c!=null){
            soql+=' and Area__c=:\''+usr.Area__c+'\'';
        }
System.Debug('Query '+soql);
        List<User_Detail__c> userDetailRecords=Database.query(soql);

Debug is: 
DEBUG|Query select id,name,Area__c,City__c,Address__c from User_Detail__c where name!=null and City__c=VIJ

Error Message: 
System.QueryException: expecting a colon, found 'VIJ'

I thought everything i have given correctly, but missed something somwhere. Will you correct me where i'm supposed to change.
Please update me your thoughts ASAP
Hello Folks,

I was not able to send an email. I have added WHATID as well, below is my code:
             mail.setToAddresses(ToUsersEmailIds);
             mail.setCCAddresses(ccUsersEmailIds);
             mail.setTemplateId(NOTIFICATION_EMAIL_TEMPLATE.Id);
             mail.setTargetObjectId(newContract.OwnerId);
             mail.setSaveAsActivity(false);
             mail.setWhatId(newContract.id);
             allMails.add(mail);
From some people i heard that i cannot add "setTargetObjectId" if i set "WhatId". But if i didn't set Targetobject Id it is throwing error, saying that required field missing.
Below is my exact error:
System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: [whatId, 800Z0000000Cixc]: Class.ContractTriggerAfter.contractOwnerNotification: line 173, column 1

Please update me with your valuable solution,
Thnx in advance!!
Hello Folks,

I was able to login to salesforce1 with the sandbox url(test.saleforce.com), but i'm not able to see any of the custom and standard objects. How can i show them in salesforce1 because we have to test some of the pages. In that NEW and VIEW buttons are overriden with VF Pages, so i want to test it. How can i enable that permission in sandbox?

Please provide me your valuable solutions ASAP.
Hello Folks,

I'm working in Professional Edition. So i don't have access for Apex. I was trying to update Contact Records from an Account Page by using Custom button(Through VF Page). 

As i understood that we can query the records by using sforce.connection.query and also we can update by using sforce.connection.update.  I need help on how to add list in vf page from a javascript.

<apex:PagebolckTable value="{!contactsForAccount}" var="c">  Showing Contact Records in editable mode in a visualforce page
    <apex:column headervalue="Last Name">
         <apex:inputfield value="{!c.LastName}"/>
    </apex:column>
</apex:PagebolckTable>

contactsForAccount - > It is the list adding in PageBlock Table, how to add records to this list in PageBlock Table.
Hi Team,

By using Publisher Action, I was trying to show one field in the visualforce page based on the ApexPages.CurrentPage().getParameters().get('id'); from the class.
I was able to show the Visualforce Page publisher Action in the mobile, but when i'm clicking on it following error is appearing. Is anyone have any idea, how to resolve this issue??
User-added image
Hello Team,

We started the Project 1 year back, now almost everything is ready also we have huge data in the system. Now is it correct/good to enable Territory Management & Forecast Management in my project because now client is seeking for that.

Or else its better to implement those TM & FM by custom entities and custom functionalities.

Which one is the best option to enable, Please provide your suggestions.
Thanks!!
  • September 11, 2015
  • Like
  • 0
Hi all,
I've tried alot of solutions for this issue but when I install the package then I received an email with exception info as below:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Please find below my code:
global class PostInstallClass implements InstallHandler {
  global void onInstall(InstallContext context) {
      User u = GetUserById(context.installerId());
      try
      {
          if(!Test.isRunningTest())          UpdatePackageInstallationInfo(context.installerId(), u.Email);
      }
      catch(Exception e)
      {
          SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + u.Email + ' tried to install/upgraed the package but failed because. Error Details: ' + e);
      }     
  }
    
    public User GetUserById(ID id)
    {
        User u = [Select Id, Email from User where Id =:id];
        return u;
    }
    
    @future(callout=true)
    public static void UpdatePackageInstallationInfo(String organizationId, String userEmail)
    {        
        String url = 'http://demoapi.sunapplabs.com/api/salesforce/updateinstallpackage?organizationid='+organizationId;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        HttpResponse responseResult = h.send(req);
        if(responseResult.getBody() == 'true')
        {            
            SendMessage(new String[]{userEmail, 'abc@xyz.com'},'Package install successful','Thanks for installing the package. Response result : '+responseResult);
        }
        else
        {
            SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + userEmail + ' tried to install/upgraed the package but failed because of failure from MyAPI response. Response result : '+responseResult);
        }
    }
    public static void SendMessage(String[] toAddresses, String subject, String message)
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('abc@xyz.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject(subject);
        mail.setPlainTextBody(message);
        Messaging.sendEmail(new Messaging.Email[] { mail }); 
    }
  }



 

I have been trying to connect Salesforce and Google API using server to server application.

 

Intent :- To communicate data between Salesforce and Google Spreadsheet which is hosted in Google Sites and using some Google Forms, Google scripts and triggers to update data.

 

So, for doing this I need a server to server application model from Google as it wouldnt require a consent from user while its communicating data. for doing this I need to create a JWT and pass it to Google to get the token and proceed with the next steps.

 

JWT for Google requires a RSA with SHA256 signing of the msg using the private key that google has provided in the certificate when I created the server to server application in Google.

I havent found this info anywhere till now :(

In salesforce, we have a crypto class in which can sign with RSA SHA1 (or) generate digest with SHA256, I tried generating a digest using SHA256 and signing that digest usng RSA and the private key given by google. Even thats not working.

 

Google isnt accepting my assertion values (JWT) and its returning an invalid Grant message.

 

I have seen that Jeff douglas has posted some information about this here :-http://blog.jeffdouglas.com/2010/07/06/using-rsa-sha1-with-salesforce-crypto-class/

But unfortunately he has mentioned about domain model and asking us to upload a certificate to google, which i dont want to do or which is not my scenario.

 

Also Google requires a UT8 base64 URL encoded value at all places as mentioned in this link :-https://developers.google.com/accounts/docs/OAuth2ServiceAccount#libraries But salesforce has a separate URL encoding and a separate base64encoding method available in the EncodingUtil class.

 

I have a C# dotnet application which is generating the same value and its able to hit Google and get the value properly. But uses the certificate file and gets the privatekey directly. I used openssl to retrieve the privatekey from the .p12 certificate file provided by Google and have pasted it in my code. I am sure there is some problem in the signing part, because when I compare the values generated by my .NET application and Salesforce Apex code, its returning correct values, but when it comes to the signature part, the length is also same for the returned data (signature) from both .NET and SF but Google returns an invalid grant while calling from SF but returns a bearer token when I call it from my .NET application.

 

public class TestRestAPICall
{
    public class JWTClaimSet
    {
       public string iss {get;set;}
       public string scope {get;set;}
       public string aud {get;set;}
       public Long exp {get;set;}
       public Long iat {get;set;}
       //public string prn {get;set;}
    }

//@future (callout=true)
public static void LoginToGoogle()
{
    //Set your username and password here        
    String clientId = '851234545868.apps.googleusercontent.com';

    //Construct HTTP request and response
    Http http = new Http();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();


    String JWTHeader =  '{"typ":"JWT","alg":"RS256"}';
    //String Base64EncodedJWTHeader = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9'; //To encode later using code

    //Taken from .net application
// Since the information is going to be same, I have encoded it already in .NET and using it here
    String Base64EncodedJWTHeader = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9';
// Salesforce returns time in milliseconds, so we are dividing it by 1000 to set the seconds value instead of milliseconds value
    Long expires_at = math.roundToLong(DateTime.now().addMinutes(40).getTime() / 1000);
    Long issued_at = math.roundToLong(DateTime.now().addSeconds(-2).getTime() / 1000);
    //Long issued_at = 1372276504;
    //Long Expires_at = 1372279804;

    JWTClaimSet JWT = new JWTClaimSet();
    //JWT.prn = username;
    JWT.iss = '851234545868@developer.gserviceaccount.com';
    JWT.scope = 'https://www.googleapis.com/auth/drive.file';
    JWT.aud = 'https://accounts.google.com/o/oauth2/token';
    JWT.iat = issued_at;
    JWT.exp = expires_at;

    String strJWTJSON = JSON.Serialize(JWT);
    system.debug('Unencoded claimset::'+strJWTJSON);


    Blob ClaimsetBlob = Blob.valueOf(strJWTJSON);
    String Base64EncodedClaimset = EncodingUtil.base64Encode(ClaimsetBlob);
    //Base64EncodedClaimset = PerformPostBase64Encode(Base64EncodedClaimset);
    system.debug('Base64 Encoded Claimset::'+Base64EncodedClaimset);

    // constructing the base64 encoded string to sign it
    string Base64EncodedString = Base64EncodedJWTHeader + '.' + Base64EncodedClaimset;


    // Steps to sign the base64Encoded string
    String algorithmName = 'RSA';
    String key = 'MIICXAIBAAKBgQCi16h+5TeQU5Fo0DlR6+YmrzYXZ7DLxz+dBEnB8Hj0gznqlz8p7nQ7I4AV/SfiJQ6JbU16sKS5IW7Hob5ieW1DfwxYZeCSBPbEkt7eASrI8xqGU5RVewaQivY3vO+avgSSUT+ZU243XsDvZJQlkE3e46FhBvFedDQvuk2iEfgdxQIDAQABAoGAFaO882f4c0h3qUsKYvWLNxbPhFq2Js5KiM4aEximqi+KEb+ZmDPk5Dr6eXGTzDyKav7IbgZtTWDA/OxkhWeHelsMB9LqBq50L6hLHTK4hHecPrT3oN4GviUXh5y5Vt479A1TopjLKdt7V4AnAs0HEWJzar/euUa+T9eODPWPFP0CQQDWQeK2cqzWSVHUpkufp7a0Sc2RvfcIpOf8kRFBLnKiFGr7BscLz6qsaG1M8TyUNMrCquwLSNSDMvPjl6sCjgRPAkEAwpFx8+lspjN0yV5M5XHPmnoddTHwV/8QHoccMBBq0ZMFs2m1E/rFhwMHRBiFN6flbze8src7YnOmmtYqsGizqwJAfqoEtYel1ikST3zgSEqGIJ9hAEAlwt56pz27zaT/8AHSHQUstzbV14cE1u/muFddZyhU03cC62078djAKIp80QJAKMMT3ofOrVsmYnGRJpibZ7+hoEXgFm9nTx37N86YsmNc1GOW/iKRc2GdChUhA7H3DT/eForwtAWKp/Gqa97jlQJBAKjKOIKvdYS9fTpCzs1nUHg9rvVartRR5xxwLH57bBincuSJSBGjwd1FInAh2tgiUGPWGPsplShP87wao9+n9VQ=';
    Blob privateKey = EncodingUtil.base64Decode(key);

    Blob input = Blob.valueOf(Base64EncodedString);
    //Blob SHA256InputBlob = Crypto.generateDigest('SHA-256',input);

    Blob Blobsign = Crypto.sign(algorithmName, input , privateKey);


    // The following line is just for debugging and viewing the blob data in signature as string and its not used anywhere
    String signature = EncodingUtil.urlEncode(EncodingUtil.convertToHex(Blobsign),'UTF-8');

    system.debug('Unencoded signature ::'+signature);
    String base64EncodedSignature = EncodingUtil.base64Encode(Blobsign); 
    //base64EncodedSignature = PerformPostBase64Encode(base64EncodedSignature);
    system.debug('Base 64 encoded signature ::'+base64EncodedSignature );

    system.debug('Encoded assertion : ' + Base64EncodedString+'.'+base64EncodedSignature);

    string URLEncodedUTF8GrantType = encodingUtil.urlEncode('urn:ietf:params:oauth:grant-type:jwt-bearer','UTF-8');
    string URLEncodedUTF8Assertion = encodingUtil.urlEncode(Base64EncodedString+'.'+base64EncodedSignature,'UTF-8');        

    system.debug('URLEncodedUTF8GrantType : ' + URLEncodedUTF8GrantType);
    system.debug('URLEncodedUTF8Assertion : ' + URLEncodedUTF8Assertion);

    //Making the call out
    req.setEndpoint('https://accounts.google.com/o/oauth2/token');
    req.setMethod('POST');
    //req.setHeader('Content-Length', '-1');
    req.setHeader('Content-Type','application/x-www-form-urlencoded');
    //req.setHeader('grant_type',URLEncodedUTF8GrantType);
    //req.setHeader('assertion',URLEncodedUTF8Assertion);
    req.setBody('grant_type='+URLEncodedUTF8GrantType+'&assertion='+URLEncodedUTF8Assertion);
    res = http.send(req);
    system.debug('Response : '+res.getBody());
}

 public static String PerformPostBase64Encode(String s)
 {
    s = s.Replace('+', '-');
    s = s.Replace('/', '_');
    s = s.Split('=')[0]; // Remove any trailing '='s
    return s;
 }
}

 

 

I have also posted my problem at stackexchange, it would be great if anyone could help me out :-

 

http://salesforce.stackexchange.com/questions/13301/connect-apex-and-google-api-using-jwt-to-retrieve-oauth-2-0-token

Hi all,

I am new for Apex development. So please help me out. Any help will be appreciable.
Currently I am using a function in our application in which I am retrieving data from external web services and storing it in Salesforce database. I am calling this function in a ‘for’ loop because this is getting called multiple times based on the selection of checkboxes. At 1st time, this function is working properly but 2nd time, It's giving exception which is as follows:
ERROR: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Below is the function which is getting called multiple times:
WebService static void getContent(String id)
{
    String response = '';
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    String url = 'url of the web service';
    req.setEndpoint(url);
    req.setMethod('GET');
    HttpResponse res=null;
    try {
        res= h.send(req);
    } catch(System.CalloutException e) {
    System.debug('ERROR: '+ e);
}

Thanks,
Manjiri

Hi

 

This is my visualforce page:

 

<apex:commandButton value="Save" action="{!Saveacc}"/>

<apex:pageblockTable value="{!fields}" var="fls">
        <apex:column value="{!fls.name}" headerValue="Label"/>
        <apex:column value="{!fls.key}" headerValue="Key"/>
        <apex:column >
         <apex:selectList value="{!selectedvalue}" size="1">
       <apex:selectOptions value="{!TagField}" id="fval" />

        </apex:selectList>

</apex:column>

</apex:pageblockTable>

 

This is my controller..

 

 

public PageReference Saveacc(){
System.debug('selected valueeeeeeeeeeee'+selectedvalue);
    Saveaccount();
    return null;
 
}

 

public SObject Saveaccount(){
    System.debug('field valueeeeeeee'+selectedvalue);
   
    List<Mandatory_Object__c> rec= new List<Mandatory_Object__c>();
    Set<string> MoNameSet=new Set<string>();
   
    for(Integer i=0; i<fields.size();i++){
        MoNameSet.add(fields[i].Name);
    }
    List<Mandatory_Object__c> insrec = [select Id,Name,Value__c,Type__c,Name__c from Mandatory_Object__c where Id!=null and Type__c =:selectedobject and Name__c = :MoNameSet];

     for(Integer i=0; i<fields.size();i++){
     Mandatory_Object__c mo = new Mandatory_Object__c();
     mo.Name__c=fields[i].name;
 
   // mo.Value__c =fields[i].val;
System.debug('field valueeeeeeee'+selectedvalue);
     mo.Value__c = selectedvalue;
     mo.Type__c = fields[i].ftype;
     rec.add(mo);
   }
   if(!rec.isEmpty()&&insrec.isEmpty()){
 insert rec;
 }
 else{
 
     update insrec;
   
 }

return null;
}

 

 

My show stopper is  I have several values in my picklist (selectedvalue).For example I have these 3 values in my picklist.

 

BillingFirstName

BillingLastName

BillingMI

 

But when ever i changed the value and trying to save the code i'm always getting first value(BillingFirstName) only.

 

 

I have geter and setter methods also for this variables.

 

 

How can I get the selected picklist values in selectedvalue attribute?

 

Anu.