• Timmy Ahluwalia
  • NEWBIE
  • 85 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 41
    Replies
Hello,
want to read the JSON file attached to the email and then create the record.
I tried to save the file to the task and try to fetch the contentdata from the contentVersion  obj it also does not help.
Code will be helpfull.
Thanks
I am calling the aura component(Record edit form) from the VF page.
When the record is not found it throws the Internal Error 500. I want to throw an custom message and how to avoid this error message.
<apex:page showHeader="false" sidebar="false" lightningStylesheets="true" standardStylesheets="false"> <apex:includeLightning /> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <script> // Here 'VfApp' Is Lightning Application Name $Lightning.use("c:VFOut1App", function() { $Lightning.createComponent("c:VFOut1", {}, "LcDisplayId", function(component) {}); }); </script> </head> <body> <div id="LcDisplayId"></div> </body> </apex:page>

 
In the below code I am trying to remove the element from the array, the splice method is failing for some reason.
 // this.productId =  {
    //     [
    //         {
    //             "Id": "a001700000802ZJAAY",
    //             "Name": "Medium Pizza",
    //             "Price__c": 9
    //         },
    //         {
    //             "Id": "a0017000007ztMUAAY",
    //             "Name": "Large Pizza",
    //             "Price__c": 10
    //         }
    //     ]
    // }
    
    handleDeleteSelected(event){
        console.log('handle Delete', JSON.stringify(event.detail))
    //    handle Delete {"Id":"a001700000802ZJAAY","Name":"Medium Pizza","Price__c":9}
        var del = event.detail.Id
        const productIndex = this.productId.findIndex(e => e.Id === del);
         const productupdate = this.productId;
  // delete the Medium Pizza from the productupdate array
        productupdate.splice(productIndex, 1)
       
      console.log('productIndex', productIndex)
        
      console.log(productupdate)
    }
Hi, i having problem with the test class. Please advise
 public static void updateFileAttachment(List<EmailMessage> newSObjects) {
    Map<id, Integer> mapcdt = new Map<id, Integer>();
    Set<Id> Ids = new Set<Id>();
    for (EmailMessage em : newSObjects) {
      Ids.add(em.ActivityId);
    }system.debug(ids);
    List<Task> tasks = new List<task>();
    tasks=[SELECT ID,Has_Attachment__c,(SELECT ID FROM ContentDocumentLinks) FROM TASK WHERE Id iN :ids ];
    system.debug('I AM HIT' + tasks);
    List<Task> taskUpdated = new List<Task>();
    if (tasks.size() > 0) {
      for (Task td : tasks) {
        if(!mapcdt.containskey(td.id)){
          mapcdt.put(td.id, td.ContentDocumentLinks.size());
        }
      }
      for (Task t : tasks) {
        system.debug('I AM HIT' + Ids);
        if (mapcdt.containskey(t.id)) {
          Integer count = mapcdt.get(t.id);
          system.debug(count);
          if (count >= 0 && t.Has_Attachment__c == false) {
            t.Has_Attachment__c = true;
            system.debug('line 23' + t.has_attachment__c);
            taskUpdated.add(t);
          }
        }
      }
      if(!taskUpdated.isEmpty()){
        update taskUpdated;
      }
    }
   
  }
  @isTest
    static void WithAttachment(){
        Profile p = [
            SELECT Id, Name
            FROM Profile
            WHERE UserType = 'Standard'
            LIMIT 1
          ];
        User u = new User();
        u.firstname = 'Test';
        u.lastname = 'Advisor';
        u.email = 'test@test.com.test';
        u.username = UserInfo.getOrganizationId() + 'test@test.ci.com';
        u.profileid = p.Id;
        u.Alias = 'testa';
        u.LanguageLocaleKey = 'en_us';
        u.TimeZoneSidKey = 'America/New_York';
        u.IsActive = true;
        u.LocaleSidKey = 'en_us';
        u.EmailEncodingKey = 'ISO-8859-1';
        insert u;
   
  Task tasks = [SELECT id, Has_Attachment__c FROM Task LIMIT 1];
    ContentVersion cv = [SELECT id FROM ContentVersion LIMIT 1];
    Id doc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id]
    .ContentDocumentId;
   
   
    EmailMessage emails = new EmailMessage();
        emails.FromAddress = u.email;
        emails.status = '3';
        emails.ToAddress = 'Test@ci.com'; 
        emails.Subject = 'Email with Attachment';
        emails.htmlBody = '<html><body><b>Hello</b></body></html>';
        emails.IsClientManaged= true;
        // emails.ContentDocumentIds =doc;
        insert emails;
        EmailMessageRelation emr = new EmailMessageRelation();
        emr.emailMessageId = emails.id;
        emr.relationId = u.id; // user id of the sender
        emr.relationType = 'FromAddress';
        insert emr;
          
      
      EmailMessage em1 = [SELECT ID, HASATTACHMENT,ContentDocumentIds, ActivityId FROM EMAILMESSAGE];
//    em1.ContentDocumentIds = doc;
//    update em1;
      system.debug(em1);
        // ContentDocumentLink cdl1 = new ContentDocumentLink();
        // cdl1.LinkedEntityId = tasks.Id;
        // cdl1.ContentDocumentId = doc;
        // cdl1.shareType = 'V';
        // insert cdl1;
       
        List<EmailMessage> lst = new List<EmailMessage>();
        lst.add(emails);
        Test.StartTest();
   /*     Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment(); 
        attachment.setFileName('attachmentFilename.pdf'); 
        attachment.setContentType('application/pdf');
        attachment.setBody(Blob.valueOf('Test Body'));
        Messaging.SingleEmailMessage emailss = new Messaging.SingleEmailMessage();             
        emailss.setToAddresses(new List<String>{'Test@ci.com'});             
        emailss.setSubject('test');             
        emailss.setPlainTextBody('test');             
        emailss.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment });            
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { emailss } );
        */
        EmailMessageTriggerHelper.updateFileAttachment(lst);
    
    
     Test.stoptest();
        List<EmailMessage> em = [SELECT ID, HASATTACHMENT,ContentDocumentIds, ActivityId FROM EMAILMESSAGE];
      
        SYSTEM.debug(em);
       
        Task  t = [SELECT id , Has_attachment__c FROM Task];
   //     System.assertEquals(t.Has_attachment__c, true);
    }
Hi 
i have created the dynamic query where I have the record id, using the schema i have built the database.query, i am unable to get the values out of this query, 
if(dfr.isNameField()){
                 query = 'SELECT Id, ' +dfr.getName()+ ' FROM ' +myobj+ ' WHERE Id =:myId';
            }
list<sobject> query = database.query(query);
for(sobject s: query){
// want ot extract he value of the Name
}
can not do the casting.
Help to solve this.
Thanks
Hello,
The chat is on the web site an the slds will fail there.
In the Embedded SnapIns Prechat form i want to hide the FirstName and the lastName. The code is pasted below, the firstname will hide but the picklist field will not show the options.
Please advice how to fix this.
Thanks

 var componentInfoArray = [];
            if(field.type === "inputSplitName"){
           componentInfoArray.push("input");
         //       attributes.input="hidden";
                 attributes.type ="hidden";
            }
     else if 
   
             (field.type === "inputSelect" && field.picklistOptions) {
              componentInfoArray.push("select");
                  attributes.options = "picklistOptions";
                attributes.input = "select";
         } else {
            componentInfoArray.push("input");
          }
 
Hi,
I want to download the transcript from the chat window in the PDF format Need help, if someone can provide the code.
Thanks
 
Hi,
I am building component where i am displaying the events of the particular date which users enter the lightning search component.
I am unable to display all the events seems like some time conversion problem.
I have tried to convert the date to GMT and then using the date to quiry the events but still i am missing the events and also the all day events.
Pleae advice.
Thanks.
Hi,
On Event object there are two fileds StartDateTime and EndDateTime,
on the aura component (not on the controller) how can i check that enddatetime of the event is greater than the startdatetime by 2 days.
then i want ot display Multiday event.
Thanks
Hi,
i have one custom datatable on the home page it has a button which calls the other component, which is adding notes, once i cancel or save the recordsit redirect to the main home page, now when we go to the next line of datatable and click the button it calls the notes component but the one from the previous datatable line.
i have debuge and checked the main component is picking   up the fresh row and the event id and then navigating service is redirecting to the other component but it still shows the prvious line event notes.

in the adding notes i am using recorddata to load the data, it seems as the tne prevous line adding notes is still open in the background and when we go to the next line it still shows the previous line notes.

Please suggest.
Thanks
HI,
I am trying to write the soql on event to fetch the custom field on USER object its failing. Please advise with some example.
Thanks
Hi,
on my Account lightning page there is a field 'Code', how can i hover over this field and get the information of the company name.
Thanks
Hi,
I want to create a lightning component which will get list of users and ability to sign on into there account.
This tool will be used by the support staff.
Hi,
I want to create a lightning component which will get list of users and ability to sign on into there account.
This tool will be used by the support staff.
Please advice.
Thanks
Hi,
my custom object has a lookup with USer object-- createdBY
i am trying to fetch the data from custom object as
createdby.name but the field is not fetching, please help with this.
Thanks
Hi,
i am generating a list of Id in one method and i want to use that list in the other method to fetch data.
My program was working but all of sudden i am getting message as Attempt to de-reference a null object.
I found that the list is not asseccible in other methods.
Hi,
There are lot of report folders I want to change the access of all the report folder to "Manage",  and couple of folders i want to add public groups which have full acess to all the folders.
May be by Meta data or programatically, please advise.
Thanks
Hi,
We have one bulkified trigger on custom object.
i want to use that same trigger to update all the records in the system, how can i execute the trigger which will update 1000 records in the system.
Thanks. 
HI,
I am trying to fetch the values from the map and then updating the field value on Account.
Having trouble, please help.
Thanks
    public MapAccount(){
       
        Map<Id, List<Contact>> mapcont = new Map<Id, List<Contact>>();
list<Account> acc= [select id,name from Account limit 5];
  
       set<ID> SetAccount = new set<ID>();
        for(Account k: acc){
            SetAccount.add(k.Id);
            mapcont.put(k.id, new list<contact>());
        }
        system.debug(mapcont);
        for(contact c:[select Accountid, firstname,lastname from contact where accountId IN :SetAccount])
            if(mapcont.containskey(c.accountid)){
                list<contact> con1 = mapcont.get(c.accountid); 
                con1.add(c);
                mapcont.put(c.id, con1);
            }
            system.debug(mapcont); 
            list<aCCOUNT> upacc = new list<Account>();
        for(account a1: acc){
            if(mapcont.containskey(a1.id)){
                account accnew = new account();
                //want to fetch the firstname from the mapcont and update account, 
                //i am unable to get the firstname from the map
                accnew.New_contact_Name__c = mapcont.get(a1.ID).firstname;

            }
        }
         }
    }
How can i get the child record in the record view form as i have a Record view form which is disp;aying data from the Account object and i want to display the contact on it.
Thanks
In the below code I am trying to remove the element from the array, the splice method is failing for some reason.
 // this.productId =  {
    //     [
    //         {
    //             "Id": "a001700000802ZJAAY",
    //             "Name": "Medium Pizza",
    //             "Price__c": 9
    //         },
    //         {
    //             "Id": "a0017000007ztMUAAY",
    //             "Name": "Large Pizza",
    //             "Price__c": 10
    //         }
    //     ]
    // }
    
    handleDeleteSelected(event){
        console.log('handle Delete', JSON.stringify(event.detail))
    //    handle Delete {"Id":"a001700000802ZJAAY","Name":"Medium Pizza","Price__c":9}
        var del = event.detail.Id
        const productIndex = this.productId.findIndex(e => e.Id === del);
         const productupdate = this.productId;
  // delete the Medium Pizza from the productupdate array
        productupdate.splice(productIndex, 1)
       
      console.log('productIndex', productIndex)
        
      console.log(productupdate)
    }
Hi 
i have created the dynamic query where I have the record id, using the schema i have built the database.query, i am unable to get the values out of this query, 
if(dfr.isNameField()){
                 query = 'SELECT Id, ' +dfr.getName()+ ' FROM ' +myobj+ ' WHERE Id =:myId';
            }
list<sobject> query = database.query(query);
for(sobject s: query){
// want ot extract he value of the Name
}
can not do the casting.
Help to solve this.
Thanks
Hi,
I am building component where i am displaying the events of the particular date which users enter the lightning search component.
I am unable to display all the events seems like some time conversion problem.
I have tried to convert the date to GMT and then using the date to quiry the events but still i am missing the events and also the all day events.
Pleae advice.
Thanks.
Hi,
On Event object there are two fileds StartDateTime and EndDateTime,
on the aura component (not on the controller) how can i check that enddatetime of the event is greater than the startdatetime by 2 days.
then i want ot display Multiday event.
Thanks
HI,
I am trying to write the soql on event to fetch the custom field on USER object its failing. Please advise with some example.
Thanks
Hi,
i am generating a list of Id in one method and i want to use that list in the other method to fetch data.
My program was working but all of sudden i am getting message as Attempt to de-reference a null object.
I found that the list is not asseccible in other methods.
Hi,
There are lot of report folders I want to change the access of all the report folder to "Manage",  and couple of folders i want to add public groups which have full acess to all the folders.
May be by Meta data or programatically, please advise.
Thanks
Hi,
We have one bulkified trigger on custom object.
i want to use that same trigger to update all the records in the system, how can i execute the trigger which will update 1000 records in the system.
Thanks. 
HI,
I am trying to fetch the values from the map and then updating the field value on Account.
Having trouble, please help.
Thanks
    public MapAccount(){
       
        Map<Id, List<Contact>> mapcont = new Map<Id, List<Contact>>();
list<Account> acc= [select id,name from Account limit 5];
  
       set<ID> SetAccount = new set<ID>();
        for(Account k: acc){
            SetAccount.add(k.Id);
            mapcont.put(k.id, new list<contact>());
        }
        system.debug(mapcont);
        for(contact c:[select Accountid, firstname,lastname from contact where accountId IN :SetAccount])
            if(mapcont.containskey(c.accountid)){
                list<contact> con1 = mapcont.get(c.accountid); 
                con1.add(c);
                mapcont.put(c.id, con1);
            }
            system.debug(mapcont); 
            list<aCCOUNT> upacc = new list<Account>();
        for(account a1: acc){
            if(mapcont.containskey(a1.id)){
                account accnew = new account();
                //want to fetch the firstname from the mapcont and update account, 
                //i am unable to get the firstname from the map
                accnew.New_contact_Name__c = mapcont.get(a1.ID).firstname;

            }
        }
         }
    }
Hi,
The code is pasted below i am getting Invalid Qury Locator. Please advise.
Thanks
for (Branch__c b : (List<Branch__c>) batch) {
            groups.put(b.Id, new Group(
                Name = 'Branch: ' + b.Name,
                Type = 'Regular',
                DoesIncludeBosses = false,
                DeveloperName = b.Id
              
    
            ));
                system.debug(batch);// Branch Id
            for (AADB_Associate__c a : b.AADB_Associates__r) {
                if (users.containsKey(a.Associate_ID__c)) {
                     system.debug(a.Associate_ID__c);
                    validGroupMembers.add(b.Id + '|' + users.get(a.Associate_ID__c));
                      system.debug(b.Id + '|' + users.get(a.Associate_ID__c));
                }
                  system.debug(a);
            }
          
        }
Hi,
Created a datatable to update the multiple records but this is not supported on the Mobile. 

So I  am iterating a record edit form and want to change the status of selected records to active.
How can i get this done.
Thanks
Hi,
I am updating the datatable rows in lightning by selecting the selectedRows() .
when I am reloading the datatable the check box, SELECTION is still checked.
How do I get the selection to be false.
Thanks