• SFDC Evangelist
  • NEWBIE
  • 55 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies
Hi Guys, I wrote the below code and test method for it, but for some reason my test method is not providing sufficient coverage for deployment. I run out of ideas on how to increase the coverage of this test method. Any advice on how to do it?

Actual code:
public class  standardiseWebsites {
 
    public static void standardiseWebsites(){
    //extracting the host from the address for websites that have web-protocol (http:// and https://)
    list<Account> accts = [SELECT Website FROM Account WHERE Website LIKE 'http://%' OR Website LIKE 'https://%'];
        for (Account acct : accts){            
            string website = acct.Website;
            Url u = new Url(acct.Website);
            acct.Website = u.getHost();
            update acct;
        }
        
      //removing first 4 digits of the address if it starts with 'www.' (non-web-protocol values)
      list<Account> accts2 = [SELECT Website FROM Account WHERE Website LIKE 'www.%'];
        for (Account acct2 : accts2){
            string website = acct2.website;
            website = website.substring(4);
            acct2.website = website;
            update acct2;
        }
    }
}
Test:
@isTest
public class standardiseWebsitesTest {
 
        static void standardiseWebsitesTest() {
        standardiseWebsites.standardiseWebsites();
    }
}

 

I have a custom field that will store the order of a related list off of the Opportunity Object.  So if item gets udpated the trigger should run through and adjust the order.  I am running into recursion errors.  I have googled for a while and haven't found a pattern that will work for me.  Any suggestion?

trigger updateTenantSortOrder on Tenant__c (before insert, before update, after delete) {
    Set<Id> opportunityIds = new Set<Id>();
    Integer order=1;

    for (Tenant__c tenant : Trigger.new) {
        // get opportunity id to be used as a key to get entire list.
        opportunityIds.add(tenant.Opportunity__c);
    }

   // Order list appropriately
    List<Tenant__c> tenants = 
          [select id,Name,TenantBySqFtSortOder__c from Tenant__c where Opportunity__c IN :opportunityIds order by Tenant_Square_Foot__c DESC LIMIT 10];

   // Update sort order field
    for (Tenant__c t : tenants) {
            t.TenantBySqFtSortOder__c =order++;
    }

    // update objects
    update tenants;
}

 

Salesforce Classic Calendar has option to view calendar for multiple users, using List Views to select specific records. Lightning now does not have similar Calendar functionality. Can we embed Classic Calendar in our Lightning Component?
Hi Guys, I wrote the below code and test method for it, but for some reason my test method is not providing sufficient coverage for deployment. I run out of ideas on how to increase the coverage of this test method. Any advice on how to do it?

Actual code:
public class  standardiseWebsites {
 
    public static void standardiseWebsites(){
    //extracting the host from the address for websites that have web-protocol (http:// and https://)
    list<Account> accts = [SELECT Website FROM Account WHERE Website LIKE 'http://%' OR Website LIKE 'https://%'];
        for (Account acct : accts){            
            string website = acct.Website;
            Url u = new Url(acct.Website);
            acct.Website = u.getHost();
            update acct;
        }
        
      //removing first 4 digits of the address if it starts with 'www.' (non-web-protocol values)
      list<Account> accts2 = [SELECT Website FROM Account WHERE Website LIKE 'www.%'];
        for (Account acct2 : accts2){
            string website = acct2.website;
            website = website.substring(4);
            acct2.website = website;
            update acct2;
        }
    }
}
Test:
@isTest
public class standardiseWebsitesTest {
 
        static void standardiseWebsitesTest() {
        standardiseWebsites.standardiseWebsites();
    }
}

 

I have a custom field that will store the order of a related list off of the Opportunity Object.  So if item gets udpated the trigger should run through and adjust the order.  I am running into recursion errors.  I have googled for a while and haven't found a pattern that will work for me.  Any suggestion?

trigger updateTenantSortOrder on Tenant__c (before insert, before update, after delete) {
    Set<Id> opportunityIds = new Set<Id>();
    Integer order=1;

    for (Tenant__c tenant : Trigger.new) {
        // get opportunity id to be used as a key to get entire list.
        opportunityIds.add(tenant.Opportunity__c);
    }

   // Order list appropriately
    List<Tenant__c> tenants = 
          [select id,Name,TenantBySqFtSortOder__c from Tenant__c where Opportunity__c IN :opportunityIds order by Tenant_Square_Foot__c DESC LIMIT 10];

   // Update sort order field
    for (Tenant__c t : tenants) {
            t.TenantBySqFtSortOder__c =order++;
    }

    // update objects
    update tenants;
}

 

I was wondering, upon creating a Lead record, I'd like the Company field to autopopulate the Lead's First Name and Last Name values, when these variables are true: 

Lead Status = New
Lead Record Type ID = 0126A000000LcZz

I tried creating a workflow rule and tried process builder but the Company field did not autopopulate. 

So, I"m guessing the next option is to create this process with Apex. 

Does this sound about right? 

Thanks!
Hello everyone , i am trying to write a trigger before oppty creation or update , populate account's ultimated parent account if it present, but not having any luck with my code, and i don't know how to fetch account's ultimated parent account based on account hirechy please help to review ,big thanks!

trigger populateultimateparentaccount on opportunity(Before Insert, Before Update) 
{
    Map <Id, Id> ultimateaccountMap = new Map <Id, Id> ();

    for (Opportunity account : trigger.new)
    {
        ultimateaccountMap.put(account.xxxxxxx, null);
    }

    for (Account account : [SELECT Id, xxxxxx FROM Account WHERE xxxxx IN :ultimateaccountMap.keySet()])
    {
        ultimateaccountMap.put(ultimateaccountMap.get(account.xxxxxx), account.Id);
    }

    List <opportunity> NewOppToUpdate = new List <opportunity> ();

    for (opportunity account : trigger.new)
    {
        if (ultimateaccountMap.containsKey(account.xxxx) 
        {
            // Existing account ultimate parent found
            Opportunity newopportunity = new Opportunity(Id = ultimateaccountMap.get(account.xxxx));
  

    update newopportunity;
}
how  to populate fields data in sfdc (i have obj A and some fields like status,description,state,pincode,phone,email,name if my conditions is name,email,phone fields are not populate and other fields are populate how to achieve it)
Hi 
Is it possible to login one user account in different different system at atime .