• @Amit Kumar Giri
  • NEWBIE
  • 100 Points
  • Member since 2018
  • Application Developer - Salesforce
  • Urban Outfitters


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 21
    Replies
Hi All,
In the code scanning, I am facing the Client Use Of Iframe Without Sandbox issue.
Scan Result:
User-added image
Can anyone please provide me any solution on this?

Thanks,
Pratik
I was planning to make a Continuation object callout form Trigger. I have a requirement to invoke asynch Webservice callout whenever records is created or updated. . Hence just wanted to know if it would be possible to make use of continuation object callout from Trigger.
I have a custom Label Address_State with Value "State *". I want to display "State" in black and "*" in Red color in Lightning page. Please suggest.
Hi Team,

Need some help to figure this out.
>> I have multiple tab opened in a service console.

User-added image
>> first tab is the standard case detail tab.
>> Last tab is a visualforce page and there is a button "Add To Case" in this page. Once i hit this button i want to refresh/reload first tab (case detail). i tried using available console method like getprimarttabId, getenclosingtabid however all this will give me the focus primary tab which is last tab.  
>> Is there a way i can refresh first tab by hitting a button from last visualforce tab ?

Appreciate any help and for your time.
 
What will be the best solution/design for a "concept of Teams for the Call center in salesforce where groups of service reps will report to a manager" ?
Hi all,
I'm trying to send an email which contains some merge field as well as attachment.but the thing is that when i'm sending an email by using apex trigger it will only sending the email with merge field and not the attachment.also when im doing the same by giving static value for the Setname and setbody method at that time i'm able to send email with attachment.wants to know what i'm missing here.

here is the code which i'm using to achieve functionality  mention above. 
//my trigger
trigger LeadCreate on Lead (after insert) {
    
    if(trigger.isafter)
    {
        if(trigger.isinsert)
        {
            sendMailOnLead.sendmailtoHR(trigger.new);
        }
        
    }

}
//helper class for the trigger
public class SendMailOnLead {
    
    
    public static list<lead> sendmailtoHR(list<lead>leads)
    {
        EmailTemplate et=[Select id from EmailTemplate where name=:'LeadDetails'];    
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        
        for(Lead l:leads)
        {
             Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
             String[] sendingTo = new String[]{'wagaskar.amit@gmail.com'};
             
             singleMail.setTargetObjectId(l.Id);
             singleMail.setTemplateId(et.Id);
             singleMail.setToAddresses(sendingTo);
            
            list<attachment>getattachment=new list<Attachment>();
             getattachment=[select id,name,body from Attachment where parentid=:l.id];
            for (Attachment a: getattachment)
            {
              Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
              efa.setFilename(a.Name);
              efa.setbody(a.Body);
              fileAttachments.add(efa);
            }
            //by using below code i'm able to send an email with attachment
            /*
             Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
              efa.setFilename( 'myAttachmentName.txt');
              efa.setbody(Blob.valueOf('Unit Test Attachment Body'));
              fileAttachments.add(efa);

            */
            singleMail.setFileAttachments(fileAttachments);
            system.debug('Attachment Added successfully');
            emails.add(singleMail);
            
            
        }
        Messaging.sendEmail(emails);
        system.debug('class run successfully');
        return leads;
    }

}
thanks,
Amit
 
On the Opportunity object, prevent non-admin users from modifying the Opportunity Name once Probability is greater than 50% and Prevent Opportunity from being deleted if Probability greater than or equal to 75%
Is there a way to programmatically get the max number of allowable queued or active scheduled/batch jobs? The Limits class looks like it has most of the limits but not getting the max number of schedulable apex jobs. I understand the standard limit is 5, but is there a case where this number can vary?
Beloe is my code:
<script type="text/javascript">
    function showBox(no) {
        var noval= document.getElementById(orderno).innerHTML;
        var box = new parent.SimpleDialog("helder"+Math.random(), true);
        parent.box = box;
        box.setTitle("Details");
        box.createDialog();
        box.setWidth(1300);
        box.setContentInnerHTML("<form method = \"POST\"action=\"https://google.com/\" target=\"orderdetil\"><input type=\"hidden\" name =\"TARGET\" value=\"https://www.w3schools.com/\" /><input type=\"submit\" id=\"clickevent\" value=\"submit\"/></form><input type=\"button\" style=\"background-color:#E01E0F;margin-top: 1px;margin-right: 2px;position:absolute;top:0;right:0;\" value=\"X\" onclick=\"box.hide();\"/><iframe name=\"orderdetail\" src=\"https://www.w3schools.com/\" height=\"500\" width=\"1280\" frameborder=\"0\" style=\"border:none; margin-left:0; margin-right: auto; height:600px;z-index:1;\"></iframe>");
        box.setupDefaultButtons();
        box.show();
            console.log('inside Click Box onload:::');
            document.getElementById("clickevent").click();
            console.log('hi:::');
            document.getElementById("clickevent").style.display = 'none';  
    }
    </script>
Wheni use the id of input in "document.getElementById("clickevent").click();"  when i open the popup window  i am getting below error "TypeError: document.getElementById(...) is null",
Please anyone help me on this.
Quick response is very helpfull for me. .
Advance in Thanks,
Sadik
Hi everyone,

I'm trying to build a test class for a trigger, and I'm running into an issue I don't fully understand. Here's the code:
 
@isTest class TestValidateCorrectSIC{
    public static void CreateTestData{
    Account acct = new Account(Name='Test Account');
    acct.Sic='1111';
    acct.NumberOfEmployees=101;
    acct.AnnualRevenue=1000000;
    insert acct;
    
    MultiplierMetadata__mdt multCheck = new MultiplierMetadata__mdt();
    multCheck.SIC__c = '1111';
    multCheck.Employee_Lower_Bound__c = 100;
    multCheck.Employee_Upper_Bound__c = 102;
    multCheck.Industry__c = 'Test';
    multCheck.Industry_Code__c = 'I';
    multCheck.Addressable_Spend_Multiplier__c = 3.0;
    insert multCheck;
    }
    
    @isTest static void testInitialValues(){
    acct.Sic='';
    system.assertequals(updatedSpendDetails, 0);
    system.assertequals(isPublic, false);
    system.assertequals(accToMult.Sic, NULL);
    system.assertequals(sicCode.size(), 0);
    system.assertequals(multiMap.addressMult, NULL);
    system.assertequals(acct.SC_Addressable_Spend__c, '');
    system.assertequals(acct.Account_Segmentation__c, '');
    system.assertequals(acct.Industry, '');
    system.assertequals(acct.Industry_Code__c, '');
    }
    
    @isTest static void testInvalidSIC(){
    acct.Sic='1110';
    try{
    update acct;
    throw new Exception('This should have failed, but instead succeeded.')
    }
    catch (Exception e){
    Boolean expectedExceptionThrown =  e.getMessage().contains('SIC not found')) ? true : false;
    System.AssertEquals(expectedExceptionThrown, true);
    system.assertequals(updatedSpendDetails, 0);
    system.assertequals(isPublic, false);
    system.assertequals(accToMult.Sic, NULL);
    system.assertequals(sicCode.size(), 0);
    system.assertequals(multiMap.addressMult, NULL);
    system.assertequals(acct.Addressable_Spend__c, '');
    system.assertequals(acct.Account_Segmentation__c, '');
    system.assertequals(acct.Industry, '');
    system.assertequals(acct.Industry_Code__c, '');
    }
    }
    
    @isTest static void testSicAdd(){
    acct.Sic = '1111';
    update acct;
    system.assert(multiMap.addressMult.size()>0, 'Error: sicCode not properly adding Account SIC to set');
    system.assert(addressMult.size()>0, 'Error: query of MultiplierMetadata__mdt table did not return and store records');
    }
        
    @isTest static void testIndustryCode(){
    acct.Sic='1111';
    update acct;
    system.assertequals(acct.Industry_Code__c, 'I');
    }
    
    @isTest static void testIndustryName(){
    acct.Sic='1111';
    update acct;
    system.assertequals(acct.Industry, 'Test');
    }
    
    @isTest static void testOneFieldBlank(){
    acct.NumberOfEmployees='';
    update acct;
    system.assertequals(acct.SIC__c, '1111');
    system.assertequals(acct.AnnualRevenue, 1000000);
    system.assertequals(updatedSpendDetails, 0);
    system.assertequals(acct.Addressable_Spend__c, '');
    system.assertequals(acct.Segment, '');
    }
    
    @isTest static void testNegativeEmployees(){
    acct.NumberOfEmployees = -1;
    system.assert(acct.SC_Addressable_Spend__c=0);
    system.assert(acct.Account_Segmentation__c='Emerging');
    }
    
    @isTest static void testPositiveEmployees(){
    acct.NumberOfEmployees = 101;
    update acct;
    system.assert(acct.);
    }
    
    @isTest static void testPutInRevenue(){
    update acct;
    system.assert(acct.Addressable_Spend__c=3000000);
    }
    
    @isTest static void testOverrideSegment(){
    acct.Account_Segmentation__c='C';
    acct.Override_Account_Segment__c=true;
    update acct;
    system.assertequals(acct.Account_Segmentation__c, 'Commercial');
    system.assertequals(acct.Segment_Calculated__c, 'SMB');
    }
    
    @isTest static void testNonOverridenSegment(){
    acct.Account_Segmentation__c='C';
    acct.Override_Account_Segment__c=false;
    update acct;
    system.assertequals(acct.Account_Segmentation__c, 'SMB');
    system.assertequals(acct.Segment_Calculated__c, 'SMB');
    }

    @isTest static void testPublicSectorSegment(){
    acct.NumberOfEmployees='';
    acct.AnnualRevenue=0;
    acct.Account_Segmentation__c='Commercial';
    acct.Sic='9621';
    update acct;
    system.assertequals(acct.Account_Segmentation__c, 'P');
    system.assertequals(acct.Segment_Calculated__c, 'P');
    }
    
}

I'm having issues when I save where it says "Error: Compile Error: Unexpected token '{'. at line 2 column 33"

I'm guessing I did something wrong in the formatting for creating my test data, but I'm not sure what. Any help is appreciated!
hi All,
 my batch is given below:-
public class BatchZendeskToSalesforce implements Database.Batchable<sObject>{
     public Database.querylocator start(Database.BatchableContext BC){
          string query;
         
         query = 'SELECT Id, Name,url__c,External_Id__c,'+
             'Group_Id__c,Shared_Tickets__c,'+
             'Shared_Comments__c,phone,Domain_Name__c,Notes__c,'+
             'Payroll_Vault__c,Zendesk_Id__c,Details__c ' +
             'FROM Account ';
         return Database.getQueryLocator(query);
    }
     public void execute(Database.BatchableContext BC, List<Account> Accounts){
        
        Set<Id> accountIds = new Set<Id>();
        for( Account acc : Accounts ){
           accountIds.add( acc.Id );   
        }
        getAccounts();
    }
    
    public static List<Account> getAccounts(){

        HttpRequest req = new HttpRequest();
        req.setMethod( 'GET' );
        String username = 'kevin@sfdcconsultants.com';
        String password = '45j2JpHB^qy*';
        Blob headerValue = Blob.valueOf( username + ':' + password );
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode( headerValue );
        req.setHeader( 'Authorization', authorizationHeader );
        req.setHeader( 'Content-Type', 'application/json' );
        req.setEndpoint( 'https://timerack.zendesk.com/api/v2/organizations.json' );
        Http binding = new Http();
        HttpResponse res = binding.send( req );
        
        Map<String, Object> results = ( Map<String, Object> )JSON.deserializeUntyped( res.getBody() );
        List<Object> lstOrganizations = ( List<Object> )results.get( 'organizations' );
        List<Map<String, Object>> customerAtt = new List< Map< String, Object >>();
        for ( Object customer : lstOrganizations ) {
            Map<String, Object> customerAttributes = ( Map< String, Object >)customer;
            customerAtt.add( customerAttributes );
        }
        List< Account > listAccountToUpsert = new List< Account >();
        for( Map< String, Object> attMap : customerAtt ){
            Account acc = new Account();
            String fullName = String.valueOf( attMap.get( 'name' ));
           /* if( fullName.split(' ').size() > 1 ){
                ct.FirstName = fullName.substring( 0, fullName.indexOf(' ') );
                ct.LastName = fullName.substring( fullName.indexOf(' ') + 1 );
            }else{
                ct.LastName = fullName;
            }*/
            //ct.email = String.valueOf( attMap.get( 'email' ));
            acc.url__c =  String.valueOf( attMap.get( 'url' ));
            acc.External_Id__c = String.valueOf( attMap.get( 'external_id' ));
            acc.Group_Id__c = String.valueOf( attMap.get( 'group_id' ));
            acc.Shared_Tickets__c = Boolean.valueOf( attMap.get( 'shared_tickets' ));
            acc.Shared_Comments__c = Boolean.valueOf( attMap.get( 'shared_comments' ));
            acc.phone = String.valueOf( attMap.get( 'phone' ));
            acc.Domain_Name__c = String.valueOf( attMap.get( 'domain_names' ));
            acc.Notes__c = String.valueOf( attMap.get( 'notes' ));
            acc.Payroll_Vault__c = String.valueOf(attMap.get('payroll_vault'));
            acc.Zendesk_Id__c = String.valueOf( attMap.get( 'id' ));
            acc.Details__c = String.valueOf(attMap.get('details'));
            
            //ct.Zendesk_Parent_Organisation_Id__c = String.valueOf( attMap.get( 'organization_id' ));
            listAccountToUpsert.add(acc);
            /*if(ct.Name == 'testBC'){
                System.assert(false, listAccountToUpsert);
            }*/
        }
        return listAccountToUpsert;
 }
     public void finish(Database.BatchableContext BC){
        
    }
}
when i run the batch its showing me error:- too many callouts
how to solve this error?
Any suggestions?
 
Hi All,
In the code scanning, I am facing the Client Use Of Iframe Without Sandbox issue.
Scan Result:
User-added image
Can anyone please provide me any solution on this?

Thanks,
Pratik
Hi All,
In the code scanning, I am facing the Client Potential XSS issue.
Scan Result:
User-added image
Can anyone please provide me any solution on this?

Thanks,
Pratik
<apex:outputPanel id="accdetails">
       <apex:outputPanel rendered="{!selectAcc.id !=Null}">
           <table><tr>
               <td>Name : {!selectAcc.Name}</td>
               <td>Id : {!selectAcc.Id}</td>
              </tr>
               <tr>
               <td>Owner : {!selectAcc.Ownerid}</td>
               <td>Rating : {!selectAcc.Rating}</td>
               </tr>
           </table>
        </apex:outputPanel>
       </apex:outputPanel>
I'm getting this error when I try to deploy my test class to production: System.AssertException: Assertion Failed: Expected: 005G0000008Mb3iIAC, Actual: 0050f000009KoD2AAK  Stack Trace: Class.TestRRMQL.testRRMQLInsertPriority: line 29, column 1. The actual is coming back as data not available and expected coming back as my user.

Can anyone help?

Here is the class: 

@isTest
private class TestRRMQL {

//-- Tests RoundRobinLeadRoutingMQL.trigger
    static testMethod void testRRMQLInsertPriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales' OR Profile.Name = 'Assoc Account Executive' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'out', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Test.startTest();
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Status = 'MQL Re-engage', Vertical_Industry__c = 'Pilates',
                             Email = 'test@rr.com', Phone = '4085551234', Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111',
                             Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        Test.stopTest();
        
        //requery and assert lead was assigned to user and last lead assignment updated
        lead = [select Id, OwnerId, Owner.Name from Lead where Id = :lead.Id];
        salesUsr = [select Id, Last_Lead_Assignment__c from User where Id = :salesUsr.Id];
        system.assertEquals(lead.OwnerId, salesUsr.Id);
        system.assertEquals(salesUsr.Last_Lead_Assignment__c.Date(), system.today());
    }
    
    
    //-- Tests RoundRobinLeadRoutingMQL.trigger
    static testMethod void testRRMQLUpdatePriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales' OR Profile.Name = 'Assoc Account Executive') and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'inb', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Vertical_Industry__c = 'Pilates', Email = 'test@rr.com', Phone = '4085551234',
                             Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111', Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        
        Test.startTest();
        lead.Status = 'MQL Re-engage'; 
        update lead;
        Test.stopTest();
        
       
       }
       }
I was planning to make a Continuation object callout form Trigger. I have a requirement to invoke asynch Webservice callout whenever records is created or updated. . Hence just wanted to know if it would be possible to make use of continuation object callout from Trigger.
I have a custom field on my Lead object, it's a pick list named LeadSource.

On my custom object "Checkout" whenever someone uses a lookup relationship to select the lead, I want it to automatically fill out a custom field on that called marketing source. I need it to do something like the code written below. I'm a C# developer by history and I'm not even sure if I need to create a new object here or if everything is already loaded.

Here is the code I wrote, I wouldn't think it would be much more complicated than this but I need help.
 
trigger <SetMaketingSource> on Checkout__c (before insert, after insert, after update) {
Lead.LeadSource = Checkout__c.Marketing_Source__c
}

 
Hi friends, 
I need solution on this requirement.  The requirement is to update the phone number on Brazil format ex: (99) 99999999. When user create or update a phone the number should be save on this format.  I tried using workflow rule with field update,  but it's not working. Is there any solution using trigger.  I need a logic for this requirement. 
Waiting for the solution. 
Thanks in advance... 
Hi all,

I created a time based workflow with an email alert. The time dependent workflow action should run 24 hours after the Rule Trigger Date and with this send an email alert.

Once the criteria are met, the workflow is firing, which is correct. But it is sending the email already once the workflow has been triggered. My expectation is to get the email at first 24 hours after the Rule Trigger Date. I am receivng the email twice: once the workflow is triggered and 24 hours+ after the Rule Trigger Date.

For example, I fired the the workflow today Wednesday at 10 am and although I am supposed to receive the first email on Thursday at 10 am, I am receiving the first email already immediately after firing the wokflow, at 10 am today. I receive a second email on Thursday at 10+ am. Why? Am I missing something? is this normal?.

There is not another  workflow firing in parallel, so I don't understand this behaviour.

This is my workflow:
 
Name of the workflow: Workflow Example Test
Object: Object_X
Criteria: Checkbox__c EQUALS True
Evaluation Criteria:	Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria

Time-Dependent Workflow Actions:
 
24 Hours After Rule Trigger Date

Email Alert: Send Example Email
From Email Address: test@gmail.com
Recipient: test2@gmail.com
Email Template: Test Email Template
Object: Object_X

I would appreciate any help.
We have a survey module setup which will be sent to our guests when a case is closed.

Previously, guests who clicks into the survey will be able to access the survey link directly. However recently, we noticed that guests were not able to access the survey page when clicking on the survey link sent to them. Instead, they were routed to the AirAsia Salesforce Login Page as shown in the attached screenshot.  but we as staff able to access the survey link only guest unable.
Could you please advice and guide us to set this up correctly please?
User-added image
Hi,

Please kindly help to resolve the above JSON Exception and also :
Unexpected character ('M' (code 77)): was expecting comma to separate OBJECT entries at input location.
Unexpected character ('P' (code 80)): was expecting comma to separate OBJECT entries at input location

All Help is Appreciated...!Thanks In advance...!

I'm looking for a method that will have a join/implode functionality.

 

I cannot seem to find an equivalent in the docs.  Does one exist in APEX?

 

Thanks