• Yogesh Malbhage 18
  • NEWBIE
  • 7 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 18
    Replies
In apex I am getting value retued by Auth.AuthToken.revokeAccess() method as true but the link is still not getting deleted.

Please help me through this.
Thanks
We are having a Community Portal. We have added a button called "Add to Home Screen" and our requirement is, on click of this button a short cut icon should get created for our portal website on android phone as well as iphone. 
So please help me to implement this using lightning components. It's really urgent.

Thanks in advance.
I can't get a lightning component that references User.ContactId to compile. Here's my code:
TestComponent.cmp
<aura:component controller="TestController"> </aura:component>


TestController.apxc
public with sharing class TestController { public void testMethod1 () { User u = [SELECT ID, ContactId FROM User LIMIT 1]; } }

When I compile the Apex class, it compiles just fine. But when I subsequently compile the lightning component, I get this error:
Failed to save TestComponent.cmp: Invalid definition for null:TestController: SELECT ID, ContactId FROM User LIMIT 1 ^ ERROR at Row:1:Column:12 No such column 'ContactId' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.: Source
I know it's ContactId because everything compiles when I remove that field from the query. Also, when I remove the controller field from the component, it compiles just fine.
I know User.ContactId exists, and the Apex part compiles fine. But for some reason, the lightning component thinks that User.ContactId doesn't exist.
Why is it doing this, and how can I fix it?
We are having a VF page that is accessible for guest user. Guest user provides his/her company details on that page. We want to implement a functionality that after entering company name and address the user should get suggestions of similar company names to pick correct information.
Is there any google api that we can implement here? Please help me through this.
apex batch class (Database.Batchable) doesn't process all the batches if batch execute method takes long time to run but within limits. 
It stops processing batches after some number of processed records and finishes unexpectedly. No error is reported, no exception is thrown

Could you please provide solution to this?
We need to implement Amazon Comprehend to get Sentiment score for the text in Apex class. But in Amazon Comprehend documentation there is no EndPoint provided. Can you  please help me through this?
We are having a requirement to show Accounts on a google map using a lightning component. Then we need to provide some actions like send email, add to campaign on right click of an Account from map. Can you please tell me what all actions we can perform from map?

Also, We need to display Hotels nearby accounts location on Map and the functionality to add those hotels in SF as an Account on click of a button. Can you please suggest me how we caan achieve this functionality ASAP?
We have uploaded a file in SF Files. The associated ContentVersion record is not returned on querying by a guest user with user license "Guest User". But it returns a row if internal SF user queries for the same. Can you please suggest a solution for the same?
We are trying to generate JWT access token. Code for the same is provided below:
 
ContentVersion cv = [SELECT VersionData FROM ContentVersion WHERE Title='einstein_platform' AND IsLatest = true];
System.debug('##cv'+cv);
String keyContents = cv.VersionData.toString();
keyContents = keyContents.replace('-----BEGIN RSA PRIVATE KEY-----', '');
keyContents = keyContents.replace('-----END RSA PRIVATE KEY-----', '');
keyContents = keyContents.replace('\n','');

JWT jwt = new JWT('RS256');
jwt.pkcs8 = keyContents;
jwt.iss = 'developer.force.com';
jwt.sub = 'abc@efg.com';
jwt.aud = 'https://api.einstein.ai/v2/oauth2/token';
jwt.exp = '3600';
String access_token = JWTBearerFlow.getAccessToken('https://api.einstein.ai/v2/oauth2/token', jwt);
System.debug('##access_token'+access_token);
 
public class JWT {
    
    public String alg {get;set;}
    public String iss {get;set;}
    public String sub {get;set;}
    public String aud {get;set;}
    public String exp {get;set;}
    public String iat {get;set;}
    public Map<String,String> claims {get;set;}
    public Integer validFor {get;set;}
    public String cert {get;set;}
    public String pkcs8 {get;set;}
    public String privateKey {get;set;}
    
    
    public static final String HS256 = 'HS256';
    public static final String RS256 = 'RS256';
    public static final String NONE = 'none';

    
    public JWT(String alg) {
        this.alg = alg;
        this.validFor = 300;
    }
    
    
    public String issue() {
    
        String jwt = '';
    
        JSONGenerator header = JSON.createGenerator(false);
        header.writeStartObject();
        header.writeStringField('alg', this.alg);
        header.writeEndObject();
        String encodedHeader = base64URLencode(Blob.valueOf(header.getAsString()));
            
        JSONGenerator body = JSON.createGenerator(false);
        body.writeStartObject();
        body.writeStringField('iss', this.iss);
        body.writeStringField('sub', this.sub);
        body.writeStringField('aud', this.aud);
        Long rightNow = (dateTime.now().getTime()/1000)+1;
        body.writeNumberField('iat', rightNow);
        body.writeNumberField('exp', (rightNow + validFor));
        if (claims != null) {
            for (String claim : claims.keySet()) {
                body.writeStringField(claim, claims.get(claim));
            }
        }
        body.writeEndObject();
        
        jwt = encodedHeader + '.' + base64URLencode(Blob.valueOf(body.getAsString()));
        
        if ( this.alg == HS256 ) {
            Blob key = EncodingUtil.base64Decode(privateKey);
            Blob signature = Crypto.generateMac('hmacSHA256',Blob.valueof(jwt),key);
            jwt += '.' + base64URLencode(signature);  
        } else if ( this.alg == RS256 ) {
            Blob signature = null;
            
            if (cert != null ) {
                signature = Crypto.signWithCertificate('rsa-sha256', Blob.valueOf(jwt), cert);
            } else {
                Blob privateKey = EncodingUtil.base64Decode(pkcs8);
                signature = Crypto.sign('rsa-sha256', Blob.valueOf(jwt), privateKey);
            }
            jwt += '.' + base64URLencode(signature);  
        } else if ( this.alg == NONE ) {
            jwt += '.';
        }
        
        return jwt;
    
    }
    

    public String base64URLencode(Blob input){ 
        String output = encodingUtil.base64Encode(input);
        output = output.replace('+', '-');
        output = output.replace('/', '_');
        while ( output.endsWith('=')){
            output = output.subString(0,output.length()-1);
        }
        return output;
    }
    

}
 
public class JWTBearerFlow {

    public static String getAccessToken(String tokenEndpoint, JWT jwt) {
    
        String access_token = null;
        try{
            String body = 'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=' + jwt.issue();
            HttpRequest req = new HttpRequest();                            
            req.setMethod('POST');
            req.setEndpoint(tokenEndpoint);
            req.setHeader('Content-type', 'application/x-www-form-urlencoded');
            req.setBody(body);
            Http http = new Http();               
            HTTPResponse res = http.send(req);
            System.debug('###res:'+res);
            System.debug('###getStatusCode:'+res.getStatusCode());
            if ( res.getStatusCode() == 200 ) {
                System.JSONParser parser = System.JSON.createParser(res.getBody());
                while (parser.nextToken() != null) {
                    if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'access_token')) {
                        parser.nextToken();
                        access_token = parser.getText();
                        break;
                    }
                }
            }
        }catch(Exception ex){
            System.debug('## Exception '+ ex.getMessage() + ex.getStackTraceString());
        }
        
        return access_token;
        
    }

}


I am getting response with status as Forbidden and error code 403. So please help me through this.
We are developing a forum using forceChatter : feed component (embedded in custom lightning component) with code
$A.createComponent("forceChatter:feed", {"type": "record", "subjectId" : ''}, function(feed) {
            var feedContainer = component.find("feedContainer");
            console.log("Feed:"+feed);
            feedContainer.set("v.body", feed);
        });
We are providing a cistom picklist with different filter options to filter feed Items but how can we apply these filter in above component?
Please help ASAP.
 
We are using following code in lightning component client-side controller:
var headerCmp = component.find("main-container").getElement();
        console.log("headerCmp:"+headerCmp.innerHTML);
        var WinPrint = window.open('', 'WinPrint', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');
        WinPrint.document.write(headerCmp.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close();

But is giving an exception as "Cannot read property 'write' of undefined". Please help me through this.
We are haning a lightning component tab on which we are providing a print option with window.print(). But header part from SF admin still remains there. Please provide a solution to hide header from print preview.
User-added image
We are fetching records from contact provided sufficient conditions and it is hitting the governor limit of rows returned. It required to fetch all these rows. Could you help me to handle this exception ASAP?
While inserting an user we are getting an exception mentioned above.
Please provide a solution ASAP as it is very ritical.
Thanks in advance!!!!
There are many more formatting tool options in rich text editor. Similarly, we want to add more options to Rich Text Area field in SF. Can you please provide me a way to do this?

Current options:

User-added image
We are implementing a Community Forum using forceChatter:publisher and forceChatter:feed components. We need to style the forceChatter:feed component according to our design. Please help me by providing the ways to style this standard component.

Original forceChatter:feed design:
User-added image

Desired Design:
User-added image

Please Help me through this ASAP as it is critical.
We are having a forum where feeds are enlisted. Currently, the user type is displayed as Customer.
User-added image
We need to set it "XYZ" but not Customer. Please help me through this.
I have a custom Rich Text Field in custom object which is used in HTML email templates. Normally this field would have images and text. The text content is visible in the email, but image is not visible in the emails received by the users.
I am using the following tag in the email template to display the rich text field (Special_notes__c):
{!custom_object__c.Special_notes__c}

Also, I tried with storing the image in Static Resourses as well as in Documents (in classic) but the bug mentioned above still continues.


what could be the possible reason and how to resolve this issue?

Thanks in advance.
Hi,

any one can suggest.

<apex:repeat value="{!lstQLI}" var="QLI"> <div style="page-break-inside:avoid; margin-top:25px;"> <p style="font-weight:bold; font-size:1em; text-decoration:bold;">{!count}. {!if(QLI.Product_Name_in_Offer__c != null, QLI.Product_Name_in_Offer__c , QLI.Name)}</p> <p style="text-indent:1em"> <apex:PageBlock rendered="{!if(!CONTAINS(QLI.Vendor_Material__r.Product_Spec__c,'xxxxxxxx') ,if(mapIdLstTS[QLI.Id] == NULL, FALSE, TRUE),FALSE)}"> <apex:PageBlockTable cellspacing="5" var="TS" value="{!mapIdLstTS[QLI.Id]}" columns="2" rendered="{!if(mapIdLstTS[QLI.Id] == NULL, FALSE, TRUE)}"> <apex:column width="25%" value="{!TS.Label__c}"/> <apex:column width="5%" /> <apex:column value="{!TS.Value__c}"/> </apex:PageBlockTable> </apex:PageBlock> <apex:PageBlock rendered="{!if(CONTAINS(QLI.Product__r.Name,'XXXXXXX') ,TRUE,FALSE)}"> <apex:outputText value="{!QLI.Vendor_Material__r.Product_Spec__c}" escape="False"/> </apex:PageBlock> </p>


ERROR MESSAGE IS : 
SObject row was retrieved via SOQL without querying the requested field: QuoteLineItem__c.Vendor_Material__r 
I can't get a lightning component that references User.ContactId to compile. Here's my code:
TestComponent.cmp
<aura:component controller="TestController"> </aura:component>


TestController.apxc
public with sharing class TestController { public void testMethod1 () { User u = [SELECT ID, ContactId FROM User LIMIT 1]; } }

When I compile the Apex class, it compiles just fine. But when I subsequently compile the lightning component, I get this error:
Failed to save TestComponent.cmp: Invalid definition for null:TestController: SELECT ID, ContactId FROM User LIMIT 1 ^ ERROR at Row:1:Column:12 No such column 'ContactId' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.: Source
I know it's ContactId because everything compiles when I remove that field from the query. Also, when I remove the controller field from the component, it compiles just fine.
I know User.ContactId exists, and the Apex part compiles fine. But for some reason, the lightning component thinks that User.ContactId doesn't exist.
Why is it doing this, and how can I fix it?
Hi 
We are building a Progressive Web App on Salesforce Sites and are having an issue:

The manifest.json file loads correctly and the serviceworker.js also loads correctly...

However when you click inspect element>Application>Add to Homescreen it gives the following error:

"Site cannot be installed: no matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest"
 
We are developing a forum using forceChatter : feed component (embedded in custom lightning component) with code
$A.createComponent("forceChatter:feed", {"type": "record", "subjectId" : ''}, function(feed) {
            var feedContainer = component.find("feedContainer");
            console.log("Feed:"+feed);
            feedContainer.set("v.body", feed);
        });
We are providing a cistom picklist with different filter options to filter feed Items but how can we apply these filter in above component?
Please help ASAP.
 
We are haning a lightning component tab on which we are providing a print option with window.print(). But header part from SF admin still remains there. Please provide a solution to hide header from print preview.
User-added image
We are fetching records from contact provided sufficient conditions and it is hitting the governor limit of rows returned. It required to fetch all these rows. Could you help me to handle this exception ASAP?
While inserting an user we are getting an exception mentioned above.
Please provide a solution ASAP as it is very ritical.
Thanks in advance!!!!
There are many more formatting tool options in rich text editor. Similarly, we want to add more options to Rich Text Area field in SF. Can you please provide me a way to do this?

Current options:

User-added image
We are implementing a Community Forum using forceChatter:publisher and forceChatter:feed components. We need to style the forceChatter:feed component according to our design. Please help me by providing the ways to style this standard component.

Original forceChatter:feed design:
User-added image

Desired Design:
User-added image

Please Help me through this ASAP as it is critical.
Hi,

I am getting "MALFORMED_QUERY : [object Object] : truncated" error in SOQL while querying on EmailMessage object. I am not getting why "MALFORMED_QUERY " and what is truncated?
Please help me out through this ASAP.

Query:
SELECT toIds FROM EmailMessage WHERE field1=tempvar AND Status__c NOT IN ('Rejected', 'Queued')
I am importing large csv using VF page. Before importing I need to Validate the data. So, I have created a validate method which reads the file and stores in a list(and do validations further). Since the file has nearly >5k records it hits CPU Time limit exception. So, i thought of passing the parsedValues to batch class and get sObject values. Below is the method i have in class,


I need to pass ParsedVal to batch class and return results to Normal class to proceed checking further methods.
Class : SPLImortGildExt
Public list<sObject> csv2sObject(list<List<string>> parsedval)
    { 
      splitObject = selectedObj.split(',');  
       SPL_BatchCsv2sObject sb = new SPL_BatchCsv2sObject(parsedval);
        Database.executeBatch(sb,200);

      return sObj; // Need to get value from Batch apex
   }
 
Batch Apex :

global void execute(Database.BatchableContext context, SObject[] records)
          list<sobject> sObj = new list<sobject>();
       
          Schema.sObjectType objectDef = Schema.getGlobalDescribe().get(splitObject[0]).getDescribe().getSObjectType();
                       
          for(list<string> head : parsedVal)
          {
            for(string col : head)
            {
             if(headerMap.containsKey(col.Trim()))
              headers.add(headerMap.get(col.Trim()));
             else
              headers.add(col);
             }
            break;
          }
            
          integer rowNum = 0; 
          
          for(list<string> row : parsedval)
          {
            if(rowNum == 0)
            {
              rowNum++; 
              continue;
            }
            
            else
            {
              sObject thisObj = objectDef.NewsObject();
                           
              integer col = 0;
              
              for(string colx : row)
              {
               
                string headerName = headers[col].trim();
                
                
                Try
                {
                       if((colx.contains('/')  || colx.contains('-'))
                      {
                      
                       datex =  (colx.contains('/')) ? colx.split('/') : colx.split('-');
                       
                         thisObj.put(headerName , Tempdate);                       
                      }
                      
                      else
                      {
                          if(headerName=='active_vod__c') 
                          {
                              thisObj.put(headerName , boolean.valueof(colx));
                          }
                          
                         
                      }

                    }
                                                 
                     col++;
                  }  // closing column for loop
                
              
              sObj.add(thisObj);  // Need to pass this values to previous class 
                
              
              rowNum++;
              } //close else
            } // close for         
        }
  
    }
Is there a way to acheive this.? 

Thanks.!

Hi,

 

I've been trying to deploy something but I keep getting the following error:

 

Failure Message: "System.NullPointerException: Attempt to de-reference a null object", Failure Stack Trace: "Class.callOut.main: line 70, column 13 External entry point"

 

line 70:

 

 

if (getLead.Web_Form_Source__c.substring(0, 2) == 'X0') {

 code:

 

 

public class callOut {
public static boolean isApexTest=false;
    public static HttpRequest buildWebServiceRequest(String pid, String gid, String pass, String getLead, String password){
        // Build the XML Request
        string body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:reg="http://webservice">' +
                          '<soapenv:Header/>' +
                          '<soapenv:Body>' +
                              '<reg:RegisterUserWithAutoId>' +
                                  '<reg:partnerID>'+pid+'</reg:partnerID>' +
                                  '<reg:partnerGuid>'+gid+'</reg:partnerGuid>' +
                                  '<reg:partnerPassword>'+pass+'</reg:partnerPassword>' +
                                  '<reg:clientName>'+getLead+'</reg:clientName>' +
                                  '<reg:clientPassword>'+password+'</reg:clientPassword>' +
                              '</reg:RegisterUserWithAutoId>' +
                          '</soapenv:Body>' +
                      '</soapenv:Envelope>';
        system.debug(body);

        //construct an HTTP request
        HttpRequest req = new HttpRequest();
        req.setHeader('content-type', 'text/xml; charset=utf-8');
        req.setHeader('Host','mitsweb.iitech.dk');
        req.setEndpoint('http://webservice');
        req.setMethod('POST');
        req.setBody(body); 
        return req;
    }
    
    public static String invokeWebService(Http h, HttpRequest req){
        //Invoke Web Service
        if(!isApexTest)
        {
        try{
        HttpResponse res = h.send(req);
        return res.getBody();
        }
        catch(Exception e){
        throw e;
        }
        }
        else{
        return '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><RegisterUserWithAutoId_testResponse xmlns="webservice"><RegisterUserWithAutoId_testResult><registrationResponse clientid="0" success="True" xmlns=""><clientName value="getLead" success="True" errorCode="0"/><password success="True" errorCode="0"/><loginName value="0" success="True" errorCode="0"/></registrationResponse></RegisterUserWithAutoId_testResult></RegisterUserWithAutoId_testResponse></soap:Body></soap:Envelope>';}
    }
    
    public static void handleWebServiceResponse(string xml, String password, String id){
        //Parse and apply logic to the res message
                    //string xml = res.getBody();
            string xmlRegex = '^.*clientid="';
            pattern xmlPattern = pattern.compile(xmlRegex);
            matcher xmlMatcher = xmlPattern.matcher(xml);
            List<String> result = xml.split(xmlRegex);
            List<String> result2 = result[1].split('\"');
            
            
            Lead getLead = [select id,name,email,Web_Form_Source__c from lead where id = :id];
            
            getLead.ClientPassword__c = password;
            getLead.ClientID__c = result2[0];
            update getLead;
      
            //send email
            SendMail.newLead(getLead.id, getLead.email, getLead.Web_Form_Source__c);          
    }
    
    @Future(callout=true)
    public static void main(Id id){
        
        Lead getLead = [select name,email,Web_Form_Source__c from lead where id = :id];
        
        if (getLead.Web_Form_Source__c.substring(0, 2) == 'X0') {
            string password = EncodingUtil.convertToHex(Crypto.generateDigest('MD5',Blob.valueOf(getLead.name + Crypto.getRandomInteger()))).substring(0, 8);
            
            String pid;
            String gid;
            String pass;
            
            //apply business logic
            if        (getLead.Web_Form_Source__c == 'X00001' || 
                       getLead.Web_Form_Source__c == 'X00002' ||
                       getLead.Web_Form_Source__c == 'X00003') {
                         pid = 'xxxx';
                         gid = 'xxxx';
                         pass = 'xxxx';
            
            // 4293938 Citi Bank Retail 1-2011
            } else if (getLead.Web_Form_Source__c == 'X00014' ||
                      getLead.Web_Form_Source__c == 'X00015' ||
                      getLead.Web_Form_Source__c == 'X00016') {
                         pid = 'xxxx';
                         gid = 'xxxx';
                         pass = 'xxxx';
                         
            // 4293946 Citi Bank Retail 2-2011
            } else if (getLead.Web_Form_Source__c == 'X00017' ||
                      getLead.Web_Form_Source__c == 'X00018' ||
                      getLead.Web_Form_Source__c == 'X00019') {
                         pid = 'xxxx';
                         gid = 'xxxx';
                         pass = 'xxxx';
                         
            // 4293948 Citi Bank Retail3-2011 Fee Based
            } else if (getLead.Web_Form_Source__c == 'X00020' ||
                      getLead.Web_Form_Source__c == 'X00021' ||
                      getLead.Web_Form_Source__c == 'X00022') {
                         pid = 'xxxx';
                         gid = 'xxxx';
                         pass = 'xxxx';
            }
            
            //now need to make web service callout

            //build the http request
            Http h = new Http();
            HttpRequest req = buildWebServiceRequest(pid, gid, pass, getLead.name, password);
   
            //invoke web service call 
            string xmlres = invokeWebService(h, req);
   
            //handling the response
            handleWebServiceResponse(xmlres, password, id);    
        }
    }
    
    static testMethod void testWebService(){
        //build the http request
        isApexTest=true;
        Lead l = new Lead();
        l.Email='test@test.com';
        l.Web_Form_Source__c='X00001';
        l.LastName='LastName';
        insert l;
    }
}

 

Someone please help me, I can't figure out what's wrong.