• DJ 367
  • NEWBIE
  • 150 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 64
    Questions
  • 55
    Replies
Hi ,

I am trying to pass value from child component to GrandChild. I am getting the value in Parent but not in GrandParent. In GrandParent I am able to alert anything but when I alert the value from child component then it not printing, it says " Name is  : undefined".

Here is my code --

<!--- Child Component bubblePhseChld-->
<!--- Child Component bubblePhseChld--> 
<template>
    <!-- Bubbule Phase example-->
    <div class="slds-m-around_small">
        <lightning-button label="Child Button"
                          variant="brand"
                          onclick={handleChildEvent}>
                        </lightning-button>
    </div>
</template>

----------

import { LightningElement,api } from 'lwc';

export default class BubblePhseChld extends LightningElement {
    @api Name = "James";
    @api Age = 22;
    @api Country = "India";

    handleChildEvent(event){

        const selectedEvent  = new  CustomEvent("condidate",
            {
                bubbles : true,
                composed : true
            }
        
        );

        this.dispatchEvent(selectedEvent);
            

    }
}

Parent Cmp
 
<!-- Parent Component: bubblePhseParent -->

<template>
    <div oncondidate={handleParentEvent}> 
        <c-bubble-phse-chld ></c-bubble-phse-chld>
    </div>
</template>

------------
import { LightningElement } from 'lwc';

export default class BubblePhseParent extends LightningElement {

    handleParentEvent(event){
        alert('Hi Im in Parent');
        alert(' Name is  : ' + event.target.Name);
        alert(' Age is  : ' + event.target.Age);
        alert(' country is  : ' + event.target.Country);
    }
}

GrandParent
 
<!-- bubblePhseGrandParent -->

<template>
    <div oncondidate={handleGrandEvent}>
             <c-bubble-phse-parent ></c-bubble-phse-parent> 
          
    </div>
</template>

------
import { LightningElement } from 'lwc';

export default class BubblePhseGrandParent extends LightningElement {

    handleGrandEvent(event){
        alert('Hi Im in Grand Parent');
        alert(' Name is  : ' + event.target.Name);
        alert(' Age is  : ' + event.target.Age);
        alert(' country is  : ' + event.target.Country);
    } 

}

​​​​​​​
  • April 24, 2020
  • Like
  • 0
Hello All,
I am uploading 50 MB file thru Vf page into salesforce using chatter, Now I want to send this file to external system, will it be possible to send this much large file thru chatter REST API. if yes can somebody help me.
Hello All,

can someone please help me to convert dataTime to 2019-05-02T14:15:17Z.
I am using below code but output is 2019-05-03T00:00:00Z  , HH:MM:SS are zero. Thanks
dateTime d = system.now();
        System.debug('***-->'+d);
        Datetime myDT = datetime.newInstance(d.year(), d.month(),d.day());
        String myDate = myDT.format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
		String formatted = myDateTime.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ');

 
Hello Everyone,
I am working on one of the requirment where I am uploading files into salesforce and sending it to external server . While I cross verify in external server , I am able to open only text fomrat other than .txt none other format is opening and (point-2) another thing is if file size is more than 5 MB it is faling to send to external server . Need help if someone has ever faced similer challage.
Thanks.
Hello All,

While I am encoding string it works file but while I am encidung list of string it throwing above error. Any suggestions? thanks
 
String bodyEncoded = EncodingUtil.base64Encode(Blob.valueOf(StrBody));
       (this is working fine)

        List<string> bodyEncoded = EncodingUtil.base64Encode(Blob.valueOf(lstStrBody));
       (This is throwing error)

 
  • April 01, 2019
  • Like
  • 0

Hello All,

I am using rest API to send record as blob to external server, Here my code is saved and running successfully but I am not receiving the blob into external server. I am getting the value in the query. Thanks

global class FileImpoLog implements Database.Batchable<sobject>,Database.AllowsCallouts {   
    global final String CRLF = '\r\n';  
    global final String CHARSET = 'UTF-8'; 
    
    global String addSimpleFormData(string paramName, string wert, final string boundary) {  
        string body = '';
        body+=('--')+boundary+(CRLF);  
        body+=('Content-Disposition: form-data; name="' + paramName + '"')+(CRLF);
        body+=('Content-Type: application/json; charset=' + CHARSET)+(CRLF);  
        body+=(CRLF);
        body+=wert+(CRLF);  
        return body;
    }
    
    global String addFileData(String paramName, String filename, String abc, final string boundary) {
        
        String body = '';  
        body+=('--')+boundary+(CRLF); 
        body+=('Content-Disposition: form-data; name="' + paramName + '"; filename="' + filename + '"')+(CRLF);
        body+=('Content-Type: application/octet-stream')+(CRLF);  
        body+=('Content-Transfer-Encoding: binary')+(CRLF); 
        body+=(CRLF); 
        body+=abc;  
        body+=(CRLF);
        
        return body;
    }
    
    global String addFileDataNew(String paramName, String filename, String abc, final string boundary) {
        
        String body = '';  
        body+=('--')+boundary+(CRLF); 
        body+=('Content-Disposition: form-data; name="' + paramName + '"; filename="' + filename + '"')+(CRLF);
        body+=('Content-Type: application/octet-stream')+(CRLF);  
        body+=('Content-Transfer-Encoding: binary')+(CRLF); 
        body+=(CRLF); 
        body+=abc;  
        //body+=(CRLF); commented bcz endstring character
        
        return body;
    }
    
    global String addCloseDelimiter(final string boundary) {
        
        String body = ''; 
        body+=('--')+boundary+('--')+(CRLF); 
        return body; 
    } 
    
    
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('Select Id,created_by__c,Document_Process_Date__c,WorkspaceId__c,Workspace_Name__c,Created_Date__c from File_Importer_Log_Entry__c where  CreatedDate = today' );

    } 

    global void execute(Database.BatchableContext BC, list<File_Importer_Log_Entry__c> obj){  
        //String boundary = '---------------JKKJLJLJLJLJL';
        //List<blob> lstBody;
        String boundary = '---------------BOUNDARY_STRING'; 
        
        Blob bodyBlb;
        for(File_Importer_Log_Entry__c M : obj){
            string fileName = 'Log'+M.Id ;
            string fileType = 'text/plain';
           bodyBlb = Blob.valueOf('Created By:'+M.created_by__c+'/n'+'Document Process Date :'+M.Document_Process_Date__c+'/n'+'WorkspaceId :'+M.WorkspaceId__c+'/n'+'Workspace Name'+M.Workspace_Name__c+'/n'+'Created Date :'+M.Created_Date__c);
           
           String body = ''; 
            body+=(CRLF); 
            
            String first =  addSimpleFormData('name', '{"doc_profile":{"name": "'+fileName+'","extension":"'+fileType+'"}}', boundary);
            body+=first; 
            String second = addFileData('file', fileName, EncodingUtil.base64Encode(bodyBlb), boundary);
            
            body+=second; 
            String third = addCloseDelimiter(boundary); 
            body+=third; 
            
            String loginToken = MSOP_iManage_Service.getLoginToken();
            String targetUrl = 'https://test.com/api/v1/folders/folderName/documents';
            HttpRequest req = new HttpRequest();
            req.setEndpoint(targetUrl);
            req.setHeader('x-auth-token', loginToken);
            req.setHeader('Content-Type', 'application/json');
            req.setMethod('POST'); 
            req.setBody(Body);
            Http http = new Http();
            HttpResponse res = http.send(req);
            system.debug('**********res : ' + res); 
        }
  
    }
    
    global void finish(Database.BatchableContext BC){                 

	}
}
  • March 27, 2019
  • Like
  • 0
Hello All,

Any way to fix this. Thanks
 
global class TEstLog implements Database.Batchable<sobject> {   
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('Select Id,Document_Process_Date__c,Workspace__c,CreatedBy.Name,Folder_Name__c,CreatedDate,CreatedById from FileImporter__c where  CreatedDate = today and Doc_Status__c != null');

    } 

    global void execute(Database.BatchableContext BC, list<Sobject> obj){  
        List<File_Importer_Log_Entry__c> lstLogEntry = new List<File_Importer_Log_Entry__c>();
        
        system.debug('lstFileImpor******' + obj); 
        for(Sobject o : obj){
            FileImporter__c  M = (FileImporter__c ) o;
            File_Importer_Log_Entry__c ML = new File_Importer_Log_Entry__c();
            ML.created_by__c = M.CreatedBy.Name;
            ML.Document_Process_Date__c = M.Document_Process_Date__c;
            ML.WorkspaceId__c = M.Workspace__c;
            ML.Workspace_Name__c = M.Folder_Name__c; 
            ML.Created_Date__c = M.CreatedDate;
            lstLogEntry.add(ML);
        }
        system.debug('lstLogEntry*******' + lstLogEntry);
        
        try{
            insert lstLogEntry;
			
        //List<blob> lstBody;
        Blob body;
        for(File_Importer_Log_Entry__c objLog : lstLogEntry){
             body = Blob.valueOf('Created By:'+objLog.created_by__c+'/n'+'Document Process Date :'+objLog.Document_Process_Date__c+'/n'+'WorkspaceId :'+objLog.WorkspaceId__c+'/n'+'Workspace Name'+objLog.Workspace_Name__c+'/n'+'Created Date :'+objLog.Created_Date__c);
            //lstBody.add(body);
        }
        
			system.debug('******body :' + body);
			String loginToken = MSOP_iManage_Service.getLoginToken();
			String targetUrl = 'https://test.com/api/v1/folders/folderName/documents';
			HttpRequest req = new HttpRequest();
			req.setEndpoint(targetUrl);
			req.setHeader('x-auth-token', loginToken);
			req.setHeader('Content-Type', 'application/json');
			req.setMethod('POST'); 
			req.setBodyAsBlob(Body);  
			//req.setBody(Body);
			Http http = new Http();
			HttpResponse res = http.send(req);
			system.debug('**********res : ' + res);  
        }catch(DmlException e){
            system.debug('***Error while inserting log entry - BatchName:FileImpoLog :' + e.getMessage());
        }
  
    }
    
    global void finish(Database.BatchableContext BC){                     

    }
}

 
  • March 27, 2019
  • Like
  • 0
Hello All,

I am querying record from one object and inserting to the other object but record is not getting inserted into another object. Can someone help me pls. Thanks

here is my code:
global class FileImpoLog implements Database.Batchable<sObject>{   
    global Database.QueryLocator start(Database.BatchableContext bc){
        date d=system.today();            
        return Database.getQueryLocator([Select Document_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById from Importer_Submit__c ]);      
    } 

    global void execute(Database.BatchableContext BC, list<Importer_Submit__c> lstFileImpor){  
        system.debug('lstFileImpor******' + lstFileImpor);
        List<Importer_Log_Entry__c> lstLogEntry = new List<Importer_Log_Entry__c>();
        for(Importer_Submit__c M : lstFileImpor){
            Importer_Log_Entry__c ML = new Importer_Log_Entry__c();
            ML.created_by__c = string.valueof(M.CreatedBy);
            ML.Document_Process_Date__c = M.Document_Process_Date__c;
            ML.Workspace_Id__c = M.Workspace__c;
            ML.Workspace_Name__c = M.Folder_Name__c;
            ML.Created_Date__c = M.CreatedDate;
        lstLogEntry.add(ML);
        }
        system.debug('lstLogEntry*******' + lstLogEntry);
        
            insert lstLogEntry;
    }
    
    global void finish(Database.BatchableContext BC){                 

    }
}

 
  • March 23, 2019
  • Like
  • 0
Hello All,

I am getting this error on REST API while sending attachment.Any help

calling callout from save method
List<Attachment> lstEmailAttachment = [select Name, body,contentType from Attachment where parentId IN: lstId]
 
   String jsonString = JSON.serializePretty(lstEmailAttachment);
   callout(jsonString,jsonStringWS);

this code is in callout method- here I am getting the error 
 
List<Attachment> documentLst = (List<Attachment>)System.JSON.deserialize(jsonString,List<Attachment>.class);



 
  • March 21, 2019
  • Like
  • 0
Hello All,

I know displaying list of value directly to vf page, however here is my requirement is while I edit the record I have the list of value in a list variable which I want to display on <ul> when page loads.
  • March 16, 2019
  • Like
  • 0
Hello All,

I am writting trigger on ContentDocumentLink but while uploading file I am getting below error. need help please.

User-added image
 
trigger tesDocUpload on ContentDocumentLink (before insert) {
	List<string> strIds = trigger.newmap.keyset() ;
	 List<ContentDocumentLink> lstContDoc= [Select Id,ContentDocumentId From ContentDocumentLink where LinkedEntityId IN: strIds ];
	
		for(ContentDocumentLink cd : lstContDoc){
			if(lstContDoc.size() > 3){
				cd.addError('Only 3 files can be uploaded!');
			}
		}
}

 
  • March 15, 2019
  • Like
  • 0
Hello All,
I am querying 'ContentDocumentLink'  in javascript visualforce and I am getting above error any way to fix this. Thanks

Here I am getting proper id value(MyId) as well.
var Content ="Select Id,ContentDocumentId From ContentDocumentLink where LinkedEntityId="  + "'MyId'" ;
			var ContentQuery = sforce.connection.query(Content);
			var records = ContentQuery.getArray('ContentQuery');

 
  • March 06, 2019
  • Like
  • 0
Hello All,

I have a urgent requirment where I need to store file of 50 MB. <apex:inputFile> does not support this much large file, I tried with the below link but I am not able to write code. 
https://hub.appirio.com/tech-blog/upload-a-file-as-large-as-2gb-in-salesforce-using-a-visualforce-page

can someone please help me to achieve this. Thanks in advance.
  • March 02, 2019
  • Like
  • 0
Hello All,
I want to send attachmnet of attachment object to an external server thru REST api, Can some one please help me with code. Thanks
  • February 26, 2019
  • Like
  • 0
Hello All,

I have an email id lets say abc@gmail.com, My requirment is whenever any email is send to abc@gmail.com it should record into email object or any custom object with the attachment. This is urgent , can someone please help me.

Thanks
  • February 13, 2019
  • Like
  • 0
Hello All,

I have a excel sheet in which I have following columns AccountName,AccountNumber,Type,Industry,Filelocation
whenever I am importing a record a new account to be created with attachment(attachment should be from location mentioned in the excel sheet)

User-added image
for example I have this data whenever I click on import button it should insert the account with attachment located in the 
C:\AccountFile.

Can someone please help me to achieve this, I have inserted the record but not able to attach file to the account.

my code is here
<apex:page controller="importDataFromCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4"> 
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Account" action="{!importCSVFile}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!accList}" var="acc">
              <apex:column value="{!acc.name}" />
              <apex:column value="{!acc.AccountNumber}" />
              <apex:column value="{!acc.Type}" />
              <apex:column value="{!acc.Accountsource}" />
              <apex:column value="{!acc.Industry }" />
        </apex:pageblocktable>
     </apex:pageBlock>
   </apex:form>
</apex:page>

controller
 
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Account>(); 
  }
  
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n'); 
            
           for(Integer i=1;i<csvFileLines.size();i++){
               Account accObj = new Account() ;
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.name = csvRecordData[0] ;             
               accObj.accountnumber = csvRecordData[1];
               accObj.Type = csvRecordData[2];
               accObj.AccountSource = csvRecordData[3];   
               accObj.Industry = csvRecordData[4];                                                                             
               acclist.add(accObj);   
           }
        //insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}

​​​​​​​

Thanks
  • January 25, 2019
  • Like
  • 0
Hello All,

I have a trigger which works fine for single record but does not work properly for while updating record thru data loader, can someone please help me to fix this.

Thanks
trigger NumberOfContRole1 on Opportunity (before update,before insert) {

    List<OpportunityContactRole> contactRolesList = [SELECT Id from OpportunityContactRole  where OpportunityId in :Trigger.new];
    system.debug('*****contactRolesList : ' + contactRolesList);
     List<Id> lstOcr = new  List<Id>();
     
    for(OpportunityContactRole OCR :contactRolesList){
        lstOcr.add(OCR.Id);
    }
    
    system.debug('*****lstOcr : ' + lstOcr);
    
    for(opportunity op : trigger.new){
        if(!lstOcr.isEmpty()){
            system.debug('*****lstOcr.size() : ' + lstOcr.size());
            op.NoOfContactRole__c= lstOcr.size();
            system.debug('*****op.NoOfContactRole__c: ' + op.NoOfContactRole__c);
        }
    } 
}

 
  • November 27, 2018
  • Like
  • 0
Hello All,

I have one input field for lookup in vf page and there is look filter on this. It is working in generally, however when I enter some text in the lookup and click next then lookup turns into picklist and suggest all the value related to entered text, I want is only value related to filter to show. Is there any way to get solution.
Thanks
  • October 25, 2018
  • Like
  • 0
Hello All,

I have a input field in visualforce page and there is helpText on it, which is working fine however once I enabled ACCESSIBILITY MODE then help text does not work properly. Does anyone know how to fix this. Thanks
  • October 25, 2018
  • Like
  • 0
Hello All,

I have a req where I have a date only and I have to add it with current time. Thanks
  • October 10, 2018
  • Like
  • 0
Hi All,

I have done a simple code however when I am runnung my test class I am getting error. 

Apex code:

public class AccountSaveCont{
    public Account acc{get;set;}
    
    public AccountSaveCont(){
       acc = new Account();
    }
    
    public void save1(){
        insert acc;
    }
}

Vf Page:

<apex:page controller="AccountSaveCont">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save1}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!acc.name}"/>
                <apex:inputField value="{!acc.site}"/>
                <apex:inputField value="{!acc.type}"/>
                <apex:inputField value="{!acc.accountNumber}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Test Class:

@isTest(seeAllData = true)
public class AccountSaveContTest{

    public static testMethod void AccountInsert(){
    
        Account a = new Account(Name='test', phone = '1234567890');
        a.Name= 'DineshTesting1';
        insert a;
      
      PageReference pr= Page.AccountSave; 
      Test.setCurrentPage(pr);
      
    AccountSaveCont m = new AccountSaveCont();
        m.save1();
    }
}
 
  • November 02, 2017
  • Like
  • 1
Hi ,

I am trying to pass value from child component to GrandChild. I am getting the value in Parent but not in GrandParent. In GrandParent I am able to alert anything but when I alert the value from child component then it not printing, it says " Name is  : undefined".

Here is my code --

<!--- Child Component bubblePhseChld-->
<!--- Child Component bubblePhseChld--> 
<template>
    <!-- Bubbule Phase example-->
    <div class="slds-m-around_small">
        <lightning-button label="Child Button"
                          variant="brand"
                          onclick={handleChildEvent}>
                        </lightning-button>
    </div>
</template>

----------

import { LightningElement,api } from 'lwc';

export default class BubblePhseChld extends LightningElement {
    @api Name = "James";
    @api Age = 22;
    @api Country = "India";

    handleChildEvent(event){

        const selectedEvent  = new  CustomEvent("condidate",
            {
                bubbles : true,
                composed : true
            }
        
        );

        this.dispatchEvent(selectedEvent);
            

    }
}

Parent Cmp
 
<!-- Parent Component: bubblePhseParent -->

<template>
    <div oncondidate={handleParentEvent}> 
        <c-bubble-phse-chld ></c-bubble-phse-chld>
    </div>
</template>

------------
import { LightningElement } from 'lwc';

export default class BubblePhseParent extends LightningElement {

    handleParentEvent(event){
        alert('Hi Im in Parent');
        alert(' Name is  : ' + event.target.Name);
        alert(' Age is  : ' + event.target.Age);
        alert(' country is  : ' + event.target.Country);
    }
}

GrandParent
 
<!-- bubblePhseGrandParent -->

<template>
    <div oncondidate={handleGrandEvent}>
             <c-bubble-phse-parent ></c-bubble-phse-parent> 
          
    </div>
</template>

------
import { LightningElement } from 'lwc';

export default class BubblePhseGrandParent extends LightningElement {

    handleGrandEvent(event){
        alert('Hi Im in Grand Parent');
        alert(' Name is  : ' + event.target.Name);
        alert(' Age is  : ' + event.target.Age);
        alert(' country is  : ' + event.target.Country);
    } 

}

​​​​​​​
  • April 24, 2020
  • Like
  • 0
Hello Everyone,
I am working on one of the requirment where I am uploading files into salesforce and sending it to external server . While I cross verify in external server , I am able to open only text fomrat other than .txt none other format is opening and (point-2) another thing is if file size is more than 5 MB it is faling to send to external server . Need help if someone has ever faced similer challage.
Thanks.
Hello All,

While I am encoding string it works file but while I am encidung list of string it throwing above error. Any suggestions? thanks
 
String bodyEncoded = EncodingUtil.base64Encode(Blob.valueOf(StrBody));
       (this is working fine)

        List<string> bodyEncoded = EncodingUtil.base64Encode(Blob.valueOf(lstStrBody));
       (This is throwing error)

 
  • April 01, 2019
  • Like
  • 0
Hello All,

Any way to fix this. Thanks
 
global class TEstLog implements Database.Batchable<sobject> {   
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('Select Id,Document_Process_Date__c,Workspace__c,CreatedBy.Name,Folder_Name__c,CreatedDate,CreatedById from FileImporter__c where  CreatedDate = today and Doc_Status__c != null');

    } 

    global void execute(Database.BatchableContext BC, list<Sobject> obj){  
        List<File_Importer_Log_Entry__c> lstLogEntry = new List<File_Importer_Log_Entry__c>();
        
        system.debug('lstFileImpor******' + obj); 
        for(Sobject o : obj){
            FileImporter__c  M = (FileImporter__c ) o;
            File_Importer_Log_Entry__c ML = new File_Importer_Log_Entry__c();
            ML.created_by__c = M.CreatedBy.Name;
            ML.Document_Process_Date__c = M.Document_Process_Date__c;
            ML.WorkspaceId__c = M.Workspace__c;
            ML.Workspace_Name__c = M.Folder_Name__c; 
            ML.Created_Date__c = M.CreatedDate;
            lstLogEntry.add(ML);
        }
        system.debug('lstLogEntry*******' + lstLogEntry);
        
        try{
            insert lstLogEntry;
			
        //List<blob> lstBody;
        Blob body;
        for(File_Importer_Log_Entry__c objLog : lstLogEntry){
             body = Blob.valueOf('Created By:'+objLog.created_by__c+'/n'+'Document Process Date :'+objLog.Document_Process_Date__c+'/n'+'WorkspaceId :'+objLog.WorkspaceId__c+'/n'+'Workspace Name'+objLog.Workspace_Name__c+'/n'+'Created Date :'+objLog.Created_Date__c);
            //lstBody.add(body);
        }
        
			system.debug('******body :' + body);
			String loginToken = MSOP_iManage_Service.getLoginToken();
			String targetUrl = 'https://test.com/api/v1/folders/folderName/documents';
			HttpRequest req = new HttpRequest();
			req.setEndpoint(targetUrl);
			req.setHeader('x-auth-token', loginToken);
			req.setHeader('Content-Type', 'application/json');
			req.setMethod('POST'); 
			req.setBodyAsBlob(Body);  
			//req.setBody(Body);
			Http http = new Http();
			HttpResponse res = http.send(req);
			system.debug('**********res : ' + res);  
        }catch(DmlException e){
            system.debug('***Error while inserting log entry - BatchName:FileImpoLog :' + e.getMessage());
        }
  
    }
    
    global void finish(Database.BatchableContext BC){                     

    }
}

 
  • March 27, 2019
  • Like
  • 0
Hello All,

I am querying record from one object and inserting to the other object but record is not getting inserted into another object. Can someone help me pls. Thanks

here is my code:
global class FileImpoLog implements Database.Batchable<sObject>{   
    global Database.QueryLocator start(Database.BatchableContext bc){
        date d=system.today();            
        return Database.getQueryLocator([Select Document_Process_Date__c,Workspace__c,Folder_Name__c,CreatedDate,CreatedById from Importer_Submit__c ]);      
    } 

    global void execute(Database.BatchableContext BC, list<Importer_Submit__c> lstFileImpor){  
        system.debug('lstFileImpor******' + lstFileImpor);
        List<Importer_Log_Entry__c> lstLogEntry = new List<Importer_Log_Entry__c>();
        for(Importer_Submit__c M : lstFileImpor){
            Importer_Log_Entry__c ML = new Importer_Log_Entry__c();
            ML.created_by__c = string.valueof(M.CreatedBy);
            ML.Document_Process_Date__c = M.Document_Process_Date__c;
            ML.Workspace_Id__c = M.Workspace__c;
            ML.Workspace_Name__c = M.Folder_Name__c;
            ML.Created_Date__c = M.CreatedDate;
        lstLogEntry.add(ML);
        }
        system.debug('lstLogEntry*******' + lstLogEntry);
        
            insert lstLogEntry;
    }
    
    global void finish(Database.BatchableContext BC){                 

    }
}

 
  • March 23, 2019
  • Like
  • 0
Hello All,

I am writting trigger on ContentDocumentLink but while uploading file I am getting below error. need help please.

User-added image
 
trigger tesDocUpload on ContentDocumentLink (before insert) {
	List<string> strIds = trigger.newmap.keyset() ;
	 List<ContentDocumentLink> lstContDoc= [Select Id,ContentDocumentId From ContentDocumentLink where LinkedEntityId IN: strIds ];
	
		for(ContentDocumentLink cd : lstContDoc){
			if(lstContDoc.size() > 3){
				cd.addError('Only 3 files can be uploaded!');
			}
		}
}

 
  • March 15, 2019
  • Like
  • 0
Hello All,
I am querying 'ContentDocumentLink'  in javascript visualforce and I am getting above error any way to fix this. Thanks

Here I am getting proper id value(MyId) as well.
var Content ="Select Id,ContentDocumentId From ContentDocumentLink where LinkedEntityId="  + "'MyId'" ;
			var ContentQuery = sforce.connection.query(Content);
			var records = ContentQuery.getArray('ContentQuery');

 
  • March 06, 2019
  • Like
  • 0
Hello All,

I have a urgent requirment where I need to store file of 50 MB. <apex:inputFile> does not support this much large file, I tried with the below link but I am not able to write code. 
https://hub.appirio.com/tech-blog/upload-a-file-as-large-as-2gb-in-salesforce-using-a-visualforce-page

can someone please help me to achieve this. Thanks in advance.
  • March 02, 2019
  • Like
  • 0
Hello All,

I have an email id lets say abc@gmail.com, My requirment is whenever any email is send to abc@gmail.com it should record into email object or any custom object with the attachment. This is urgent , can someone please help me.

Thanks
  • February 13, 2019
  • Like
  • 0
Hello All,

I have a excel sheet in which I have following columns AccountName,AccountNumber,Type,Industry,Filelocation
whenever I am importing a record a new account to be created with attachment(attachment should be from location mentioned in the excel sheet)

User-added image
for example I have this data whenever I click on import button it should insert the account with attachment located in the 
C:\AccountFile.

Can someone please help me to achieve this, I have inserted the record but not able to attach file to the account.

my code is here
<apex:page controller="importDataFromCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4"> 
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Account" action="{!importCSVFile}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!accList}" var="acc">
              <apex:column value="{!acc.name}" />
              <apex:column value="{!acc.AccountNumber}" />
              <apex:column value="{!acc.Type}" />
              <apex:column value="{!acc.Accountsource}" />
              <apex:column value="{!acc.Industry }" />
        </apex:pageblocktable>
     </apex:pageBlock>
   </apex:form>
</apex:page>

controller
 
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Account>(); 
  }
  
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n'); 
            
           for(Integer i=1;i<csvFileLines.size();i++){
               Account accObj = new Account() ;
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.name = csvRecordData[0] ;             
               accObj.accountnumber = csvRecordData[1];
               accObj.Type = csvRecordData[2];
               accObj.AccountSource = csvRecordData[3];   
               accObj.Industry = csvRecordData[4];                                                                             
               acclist.add(accObj);   
           }
        //insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}

​​​​​​​

Thanks
  • January 25, 2019
  • Like
  • 0
Hi,

I am sending a large attachment from salesforce to an external system. While sending the attachments I am facing some issue, I am not able to send attachments size is greater than 12 MB, is there any possibility to send the attachments 12 MB?

Please let me know how to achieve this.

Thanks,
Vijay

hi all,

 

I have a list of String and want to convert to Blob data type, so which API method can help me to do this? I only know the Encodingutil.base64Decode(String) method, but each String in my List contains a large numbers of characters, if i append Strings the limitation exception has been raised. Please, help me!!!