• Arun_Kharb
  • NEWBIE
  • 95 Points
  • Member since 2016

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 23
    Replies

I'm creating a REST API that an external system needs to post notifications to.

The notifications contain some sensitive data so it would like to authenticate to the REST API but their system can only handle basic authentication using a username and password... no handshakes, no requesting/storing/exchanging of tokens and not even a Client ID and Password. (That is the authentication mechanism that I use to post requests to their system as well).

Is there any means to do that with Salesforce? Publicly exposed API is not an option, nor is username-password based oAuth2. Any reasonable workarounds?

Thanks y'all!

Hello,

I want to realize below use case in Apex code

1) go to below url www.wxyztest.com/abcd
2) convert that webpage to Pdf
3) Attach that Pdf to a Quote

I am more interested in the forst two parts.

thanks for suggestion !
  • March 29, 2017
  • Like
  • 0
The js code that call the apex function is 
function validate()
{
    //  alert("here");
     username=j$('[id$=email]').val();
    
        alert("here ");

    password=j$('[id$=pass]').val();
    // alert(username + "  " +password);
    
 if((username=='') || (password==''))
     {
      document.getElementById("hello").innerHTML="username or password is null";
      return false;   
         }
             
  
   var result= apiToolKitToGetAllCustUser();
    if(result==1)
        {
  alert("in result 1");
            pageRedirectAF(2); // it is the vf actionFunction
             
         }   
            return false;
    }

The vf page code is as follows
 
<button type="submit" class="btn btn-default" onclick="return validate();">login</button>
      <apex:actionFunction action="{!pageRedirectFn}" name="pageRedirectAF">
            <apex:param name="pageData" id="pageData" value="3" assignTo="{!pageData}"/>

     </apex:actionFunction>

Apex Code is as follows :
 
public class custLogin_CC {
    
    public String username{get;set;}
    public String password{get;set;}
    List<CustomUser__c> allUsers{get;set;}
    public Integer pageData{get;set;}
    
    public custLogin_CC()
    {
        
        allUsers=[select Mid__c,password__c,userEmail__c,userName__c from CustomUser__c];
        //pageData=2; if i uncomment this ,it works strangely
        
        
    }
    
    public PageReference pageRedirectFn()
    {
                PageReference pg=null;
           String s= system.CurrentPageReference().getParameters().get('pageData');
                System.debug('pageredirect function called '+ pageData +'   ss ' + s);

        if(pageData==1)
                        pg=new PageReference('/apex/IF_AllQuestionPage_Vf');
        else
                                    pg=new PageReference('/apex/IF_createQuestion_Vf');

        return pg;
        

            
    }
}

Inside constructor in apex class , at line number 12 , if i uncomment the code , the pageData is always 2 at  the pageRedirectFn function. If i comment that line ,then things are working fine.IThe value i pass through the js is auto assigned to the pageData. I want to know if pageData(ie the param variable in vf) shouldn't be initialised if used in param?
I just need to know why it behaves in this way?

Thanks and Regards,
Shiva RV

 
Hi All,
I have created one salesforce community and have Configured Single Sign on where Identity provider is an external website. 
Now I want to display this community in an Iframe under that external website after logging in a user via Single Sign On.
Can someone please help me on this.

Thanks
Hi All,
I have created one salesforce community and have Configured Single Sign on where Identity provider is an external website. 
Now I want to display this community in an Iframe under that external website after logging in a user via Single Sign On.
Can someone please help me on this.

Thanks

I'm creating a REST API that an external system needs to post notifications to.

The notifications contain some sensitive data so it would like to authenticate to the REST API but their system can only handle basic authentication using a username and password... no handshakes, no requesting/storing/exchanging of tokens and not even a Client ID and Password. (That is the authentication mechanism that I use to post requests to their system as well).

Is there any means to do that with Salesforce? Publicly exposed API is not an option, nor is username-password based oAuth2. Any reasonable workarounds?

Thanks y'all!

I have a apex:selectList on my VF page and a controller variable is bound to it. But whenever i select anything in the list, it stores a blank in the  controller variable. I am facing this problem only when i run my page on Firefox or IE. It works fine in Chrome.
My selectList is as follows:
 <apex:selectList id="objectList" onchange="$('#err2').hide(); oOptVal=this.value;"  styleClass="select-menu" style="padding-left: 10px;" value="{!selectobject}" size="1" >     
          <apex:selectOption itemValue="None" itemLabel="Please select" />                   
          <apex:selectOption itemValue="Account" itemLabel="Account" />
          <apex:selectOption itemValue="Contact" itemLabel="Contact"/> 
          <apex:selectOption itemValue="Lead" itemLabel="Lead" />
  </apex:selectList>
The bound variable is also declared correctly,
public String selectobject{get;set;}

Still, it throws a blank value whenever anything is selected.
Can anyone help in fixing this? 
Thanks & Regards
Shubham Jha

Hi guys,

I am new to Apex and APIs. I am trying to retrieve Create Date and Modified date of all fields of a custom object. I have already tried the below

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_describe.htm

When I paste the below API request in the browser
https://xxxx.salesforce.com/services/data/v20.0/sobjects/Account/describe/ -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxx"
I get an error saying "This XML file does not appear to have any style information associated with it. The document tree is shown below.
<errorCode>INVALID_SESSION_ID</errorCode>
<message>Session expired or invalid</message>
"
Does this work for custom objects? Can someone point full material for this (how to include additional parameters in the API request etc)

 

Hi,

Is there any API to get edition details for user or org? We need to manually export/ create lead in salesforce from our website which requires api access. As some of the editions do not have API access we would like to show user a warning if need be.

Thanks,
Sourav
public class Send_Data_To_NFS2{ 
    public string result;             
    public HttpResponse res;   
    
    public string reqResMethod(string strJSON, string strEndPoint){
        Http h = new Http();
        HttpRequest req = new HttpRequest();  
        req.setHeader('Content-Type','application/json');        
        string strJSONBody = strJSON;        
        req.setBody(strJSONBody);
        req.setMethod('POST');
        req.setEndpoint(strEndPoint);
        res = h.send(req);
        result = res.getBody();          
        result = result.replace('\\', '').removeStart('"').removeEnd('"'); 
        system.debug('*****res****'+res);         
        system.debug('*****res.getbody****'+result);                
        return result;
    }
        
    Public void push_Data(){            
  
        string strJSON = '-------------------------------------------------------------';
  
        string strEndPoint = '---------------------------------------------------------';
        string resp = reqResMethod(strJSON, strEndPoint);
        
  
        NFSWrapper deserializedResponse = (NFSWrapper)JSON.deserialize(resp, NFSWrapper.class);                  
  
        
        secondResponse deserializedResponse1;
        if(deserializedResponse != null && deserializedResponse.StatusCode == '200'){  
  
  
            string strJSON1 = '------------------------------------------------------------------------';  
            string strEndPoint1 = '-------------------------------------------';

            string resp1 = reqResMethod(strJSON1, strEndPoint1);
            
            deserializedResponse1 = (secondResponse)JSON.deserialize(resp1, secondResponse.class);
            
            
            if(deserializedResponse1 != null && deserializedResponse1.StatusCode == '200'){
            
            Attachment att = new Attachment();
            att = [select name, body from Attachment where ParentId = '*********************'];
            string fileBody = EncodingUtil.base64Encode(att.Body);
            system.debug('**************file body**************' + fileBody);                       
            string url = '----------------------------------------------------------------------';
            url = url + deserializedResponse1.OpportunityId;
            url = url + '&filename=test.pdf';       
            string resp2 = reqResMethod(filebody, url);
            
            //3rd POST Deserilaization
            thirdResponse deserializedResponse2 = (thirdResponse)JSON.deserialize(resp2, thirdResponse.class);
            if(deserializedResponse2 != null && deserializedResponse2.StatusCode == '200'){
                system.debug('*****ATTACHMENT ADDED SUCCESSFULLY****');
            }
            
            else{
                system.debug('*****ERROR MESSAGE****' + deserializedResponse2.Message);
            }
            
        }else{
            system.debug('*****BAD REQUEST2****');
            system.debug('*****MESSAGE****'+ deserializedResponse.Message);
        }
        
                   
            
        }else{            
            system.debug('*****BAD REQUEST1****');
            system.debug('*****MESSAGE****'+ deserializedResponse1.Message);
        }
        
    }       
    
    //Wrapper Classes
    
    public class Nttrapper{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public string[] ContactIds;        
        public String BrokerId;
        public cls_Addresses[] Addresses;
        public String AccountId;
    }        

   public class cls_Addresses {
        public String type;
        public String Id;  
    }
    
    public class secondResponse{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public String BSNumber;
    }
    
    public class thirdResponse{
        public String StatusCode;
        public String Message;
      
    }   
}
Hi,
Can you write an apex trigger to assign all incoming leads in a Round-Robin fashion to users based on the following criteria
 
1.If the lead RecordType = ‘US Lead’, then assign the lead to users with country = ‘USA’
2.If the lead RecordType = ‘International’, then assign the lead to users with Country != ‘USA’
For eg., if there are only 3 users(User1,User2,User3) with country = ‘USA’ in the system then the first lead with RecordType = ‘US Lead’ will be assigned to User1, Second lead with RecordType = ‘US Lead’ will be assigned to User2 and so on.
The same logic applies to international leads.
Thanks in Advance..
 
I am using soap api for salesforce login authentication in c# but getting below error.
UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.
So I have already deactivated "Critical Updates" in salesforce but still getting same error.
I am running below menioned SOQL query in my code- 

'select Id, Name,BILLINGSTREET, BILLINGCITY,'+ BILLINGSTATE,BILLINGPOSTALCODE,BILLINGCOUNTRY,CORPORATE_MEMBERSHIP_FORCED_LAPSE_DATE__C,'+
 'SHIPPINGSTREET,SHIPPINGCITY, SHIPPINGSTATE, SHIPPINGPOSTALCODE, SHIPPINGCOUNTRY, PHONE,FAX,'+ 'ACCOUNTSOURCE, Billing_Country_Code__c,Shipping_Country_Code__c,'+
        '(Select Id, MD_Head_of_Household__c, Salutation, firstName, LastName, MailingStreet,MailingCity, MailingState, MailingCountry,'  +
            'MailingPostalCode,Birthdate,Email,HomePhone,MobilePhone from Contacts) ' +
       'from Account where Sync__c = false AND Sync_Timestamp__c >=: startDateTime AND IsDeleted = FALSE order by Sync_Timestamp__c,Id ASC limit '+qLimit+' Offset '+qOffset';

This is query is working fine is TST sandbox but it is giving SOQL query timeout exception in UAT sandbox.
Both sandboxes are Full copy sandboxes and having same data.

Any hep/suggestion would be greatly appreciated.
I created wrapper class to relate 15 child records of the same object(ex:Territory__c has parent_Territory__c(lookup field of Territory__c))
There is a limitation in salesforce that we cant query more than 5 relationships.
If anyone has any idea to query 15 related child records please help me....!!

Thanks,
Jessy.
Hello,

I want to realize below use case in Apex code

1) go to below url www.wxyztest.com/abcd
2) convert that webpage to Pdf
3) Attach that Pdf to a Quote

I am more interested in the forst two parts.

thanks for suggestion !
  • March 29, 2017
  • Like
  • 0
The js code that call the apex function is 
function validate()
{
    //  alert("here");
     username=j$('[id$=email]').val();
    
        alert("here ");

    password=j$('[id$=pass]').val();
    // alert(username + "  " +password);
    
 if((username=='') || (password==''))
     {
      document.getElementById("hello").innerHTML="username or password is null";
      return false;   
         }
             
  
   var result= apiToolKitToGetAllCustUser();
    if(result==1)
        {
  alert("in result 1");
            pageRedirectAF(2); // it is the vf actionFunction
             
         }   
            return false;
    }

The vf page code is as follows
 
<button type="submit" class="btn btn-default" onclick="return validate();">login</button>
      <apex:actionFunction action="{!pageRedirectFn}" name="pageRedirectAF">
            <apex:param name="pageData" id="pageData" value="3" assignTo="{!pageData}"/>

     </apex:actionFunction>

Apex Code is as follows :
 
public class custLogin_CC {
    
    public String username{get;set;}
    public String password{get;set;}
    List<CustomUser__c> allUsers{get;set;}
    public Integer pageData{get;set;}
    
    public custLogin_CC()
    {
        
        allUsers=[select Mid__c,password__c,userEmail__c,userName__c from CustomUser__c];
        //pageData=2; if i uncomment this ,it works strangely
        
        
    }
    
    public PageReference pageRedirectFn()
    {
                PageReference pg=null;
           String s= system.CurrentPageReference().getParameters().get('pageData');
                System.debug('pageredirect function called '+ pageData +'   ss ' + s);

        if(pageData==1)
                        pg=new PageReference('/apex/IF_AllQuestionPage_Vf');
        else
                                    pg=new PageReference('/apex/IF_createQuestion_Vf');

        return pg;
        

            
    }
}

Inside constructor in apex class , at line number 12 , if i uncomment the code , the pageData is always 2 at  the pageRedirectFn function. If i comment that line ,then things are working fine.IThe value i pass through the js is auto assigned to the pageData. I want to know if pageData(ie the param variable in vf) shouldn't be initialised if used in param?
I just need to know why it behaves in this way?

Thanks and Regards,
Shiva RV

 

Hi Guys,

I'm trying to call an external API using a http class which looks like this:

String jsonBody = '{"CoverState":"NSW","CoverType":"S","HospitalProductId":29,"ExtrasProductId":34,"RebateFlag":"N","EffectiveDate":"12/02/2017","BillingFrequency":1,"Member1Age":0,"Member2Age":0,"payDirectDebit":"Y","maxAge":53,"rebateTier":3,"groupingid":0,"member1lhcPercentage":"46","member2lhcPercentage":"0","RebatePercent":0}';      
 String requestBody = JSON.serializePretty(jsonBody);   
 
 Http h = new Http();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
 
 
    req.setEndpoint('http://10.x.x.xxx:xxxx/xxx/xxxx/xxxx');
    req.setMethod('POST');
    req.setHeader('Content-Type', 'application/json');       
    req.setBody(requestBody);

 System.Debug('@@@ req.getHeader'+req.getHeader('req.getHeader; '+'Content-Length'));
    System.Debug('@@@ req: '+req);
    System.Debug('@@@ req.getBody'+req.getBody());
   
 res = h.send(req);
 System.Debug('@@@ res: === '+res);
 
 String auth = res.getBody();
 System.Debug('@@@ Debug(auth:'+auth);

It's giving me a 403 forbidden error when a send this using the dev console in Salesforce.

I've set up a remote access URL in Salesforce and also enabled API for my account.

If anyone could help that would be greatly appreciated.

Cheers,
 

Corey