• SFDC_BigDog
  • NEWBIE
  • 140 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 43
    Questions
  • 38
    Replies
public class AddPrimaryContact implements Queueable {
Private Contact conl = new Contact();
Private String sty;
Public List<Contact> coninsert = new List<Contact>();

public AddPrimaryContact(Contact conlist, String str)
{
    this.conl = conlist;
    this.sty= str;
}


public void execute(QueueableContext context)
{
    for(List<Account> acclist: [Select id,name from Account where BillingState =:sty]);
    {
        for(Account accops:acclist)// Error in this statement
        {
            conl.lastname = 'testLast';
            conl.accountid = accops.id;
             coninsert.add(conl);
        }
    }

    if(coninsert.size()>0)
    {
        insert coninsert;
    }
}}


I am trying Queueable Apex challenge in trial head. In the code I am getting an error in the for loop. Correct me if I am wrong in the below code.
Error: Variable does not exist: acclist

 

Thanks for help!

We are seeing this error whenever our .net developer is trying to insert a record into salesforce custom object.

sObject type 'xyz__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

They have integrated using latest Enterprise WSDL. The user is set as "System Administrator". Besides all these we are seeing this error. We are not seeing this issue with Standard objects.

Any insights would be helpful.

Thank you.

I have a custom button to send an email. The code is working fine. Now I would like to insert those email in the activity history. I did set mail.setSaveAsActivity(true). But when I click the button it is showing the error as: I am unable to resolve this. Any help is appreciated. The following is my code.
User-added image

Apex Class Code:
 

global class memberApproval {

webservice static boolean callApproval(Id localId) { 
            set<Id> Uid = new set<Id>();
            String grpId = Label.GroupId;
     List<GroupMember> Lst =[Select Id, UserOrGroupId From GroupMember Where GroupId =: grpId];
     if(Lst.size()>0){
     opportunity opp =[select id,owner.email from opportunity where Id =:localId];
     for(GroupMember g:Lst){
         Uid.add(g.UserOrGroupId);
     }

     if(Uid.size()>0){
     List<User> Lstuser = [select id,email from user where Id In:Uid];
     if(Lstuser.size()>0){

     List<String> EmailIds = new List<string>();


     for(User u:Lstuser){
     EmailIds.add(u.Email);
     }
       //New instance of a single email message
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        // Who you are sending the email to

           mail.setToAddresses( EmailIds  );
        String templateIdVal= Label.TemplateId;
       String[] bccEmail = new String[]{opp.owner.email};

           // The email template ID used for the email
           mail.setTemplateId(templateIdVal);
           mail.setTargetObjectId(userinfo.getuseriD());
           mail.setwhatid(opp.id);
           mail.setBccSender(true);
           mail.setBccAddresses(bccEmail);
           mail.setUseSignature(false);
           mail.setReplyTo(opp.owner.email);
           mail.setSenderDisplayName('Confirmation of Order Quote');
           mail.setSaveAsActivity(true);  

        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
     }
     }
     }
    return true;               
}
}
Custom Button Code:
 
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 
sforce.connection.sessionId = "{!$Api.Session_ID}"; 


var contactCheck = sforce.connection.query("SELECT id from Attachment where parentid = '{!Opportunity.Id}'"); 
records = contactCheck.getArray("records"); 
if(records.length == 0){ 
alert('With out Attachment you can not send Email'); 

}else{ 
sforce.apex.execute("memberApproval","callApproval",{localId:"{!Opportunity.Id}"}); 
alert("Email Sent."); 

}


 
I am unable to resolve my test class. Before including trigger.oldmap it was 80% coverage. Now it is 0%. Any suggestions could be helpful for me.

Thank you.

Trigger:
trigger populateOpportunityfromContact on Opportunity (before insert , before update)
{
    
    Set<ID> ConIds = new Set<ID>();

    for(Opportunity opp : trigger.new)
    {
          ConIds.add(opp.RSM_Shipping_Contact__c);    
    }

    list <contact> conlist = [SELECT Email,Id,MailingCity,MailingCountry,MailingPostalCode,MailingState,MailingStreet,Phone FROM Contact where id IN:ConIds];

     MAP<ID , contact> mapCon = new MAP<ID , Contact>();
     for(Contact c : conlist)
     {
        mapcon.put(c.id,c);
     }

     for(Opportunity opp : trigger.new)
     {
      if(trigger.oldmap.get(opp.Id).RSM_Shipping_Contact__c != opp.RSM_Shipping_Contact__c)
      {

        if(opp.RSM_Shipping_Contact__c!=null)
        {
        if(mapcon.containskey(opp.RSM_Shipping_Contact__c))
        {
          contact c = mapcon.get(opp.RSM_Shipping_Contact__c);
          opp.Shipping_Street__c = c.MailingStreet;
          opp.Shipping_City__c = c.MailingCity;
          opp.Shipping_State__c = c.MailingState;
          opp.Shipping_Country__c= c.MailingCountry;
          opp.Shipping_postal_code__c = c.MailingPostalCode;
          opp.Shipping_Email__c = c.Email;
          opp.Shipping_Phone__c = c.phone;
        }
       
        }
        
        else
        {
            
          opp.Shipping_Street__c = null;
          opp.Shipping_City__c = null;
          opp.Shipping_State__c = null;
          opp.Shipping_Country__c= null;
          opp.Shipping_postal_code__c = null;
          opp.Shipping_Email__c = null;
          opp.Shipping_Phone__c = null;
            
        }
       
     }
    }
        
}

Test Class:
 
@istest

public class populateOpportunityfromContactTestclass
{
     @testSetup static void setup() 
      {
                
        contact c = new contact();
        c.lastname = 'Gopi Jayaram';
        c.mailingstreet = '1409 Roper Mountain Road';
        c.mailingcity = 'Greenville';
        c.mailingstate = 'South Carolina';
        c.mailingcountry = 'United State of America';
        c.mailingpostalcode = '29615';
        c.email = 'gopijayaram@gmail.com';
        c.phone = '4053786543';
        insert c;
        
        
        opportunity o = new opportunity();
        o.name = 'Gopi Jayaram ATT';
        o.RSM_Shipping_Contact__c = c.id;
        o.stagename = 'prospecting';
        o.closedate = Date.today();
        insert o;

     }
     
     Static testMethod void insertItemNull()
     {
         Opportunity op = [Select id, name,Shipping_Street__c from opportunity where name = 'Gopi Jayaram ATT' ];
        // contact ct = [Select id,email,phone,mailingstreet,mailingcity,mailingstate,mailingcountry,mailingpostalcode from contact where name = 'Gopi Jayaram' ];
         System.assertnotequals(op.Shipping_Street__c,null);
     } 
      Static testMethod void insertItem()
     {
         Opportunity op = [Select id, name,Shipping_Street__c from opportunity where name = 'Gopi Jayaram ATT' ];
        contact ct = [Select id,email,phone,mailingstreet,mailingcity,mailingstate,mailingcountry,mailingpostalcode from contact where name = 'Gopi Jayaram' ];
         System.assertequals(op.Shipping_Street__c,ct.mailingstreet);
     } 
     
}

 
I have 100% code coverage when I tested it in the Sandbox. When I have uploaded the same in the production using changesets, I am getting code coverage error as 53%. What might be the issue. This code for a custom button to send an email for a public group. I have all those deployed in production. Now when I am trying classes, I am getting code coverage error. I have used hardcoded values in my code. Id's of template and group. But when I deployed the email template and Group in production the values change. So is that the problem? How can I do to prevent hard coding values into the code.
 
global class memberApproval {

    webservice static boolean callApproval(Id localId) { 
                set<Id> Uid = new set<Id>();
         List<GroupMember> Lst =[Select Id, UserOrGroupId From GroupMember Where GroupId = '00G19000000YJRC'];
         if(Lst.size()>0){
         for(GroupMember g:Lst){
             Uid.add(g.UserOrGroupId);
         }

         if(Uid.size()>0){
         List<User> Lstuser = [select id,email from user where Id In:Uid];
         if(Lstuser.size()>0){

         List<String> EmailIds = new List<string>();


         for(User u:Lstuser){
         EmailIds.add(u.Email);
         }
           //New instance of a single email message
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

            // Who you are sending the email to

               mail.setToAddresses( EmailIds  );

               // The email template ID used for the email
               mail.setTemplateId('00X19000000Dm14');
               mail.setTargetObjectId(userinfo.getuserid());      
               mail.setWhatId(localId);   
               mail.setBccSender(false);
               mail.setUseSignature(false);
               mail.setReplyTo('v.reddy@thegordiangroup.com');
               mail.setSenderDisplayName('Confirmation of Order Quote');
               mail.setSaveAsActivity(false);  

            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
         }
         }
         }
        return true;               
    }
}
 
@isTest 

public with sharing class Test_Classnow {
  static testMethod void validateHelloWorld() {

    Group testGroup = new Group();
        testGroup.Name = 'testGroup';
        testGroup.DeveloperName = 'ABC';
        INSERT testGroup;

         Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User u = new User(Alias = 'standt', Email='standsdgser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='stangsgduser@testorg.com');

            insert u;


            GroupMember gm= new GroupMember(); 
            gm.GroupId=testGroup.id;
            gm.UserOrGroupId = u.id;
            insert gm;

            // insert opportunity and pass opp id instead of gm.id

      boolean result= memberApproval.callApproval(gm.id);
      system.assertequals(result,true);

  }



}



 
I have tried this code for custom button for single click email sending. Unfortunately It is not working and showing error. Could anyone tell me where I am doing wrong and correct me please.

Thank you.
location.replace('/email/author/emailauthor.jsp retURL=/{!Opportunity.Id}&p24="varunreddypenna@gmail.com,v.reddy@thegordiangroup.com"&template_id="00Xj0000000J8sI"&p3_lkid={!Opportunity.Id}&p3={!Opportunity.Name}&p26={!User.Email}&p5="penna.janareddy@gmail.com"&save=0')
User-added image
User-added image

 
I have created a formula field. After saving the record I am able to see the formula field with data and I am unable to in line edit from there. I would like to enable inline edit for the fields which display lock icon. Suggest me anyway that I can achieve that.

Thank you.
I have created a custom button on Opportunity. The custom button has following javascript code. When the user clicks on the button the email should be sent.I find no errors in the code. But I am not able to send any emails.
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
(function() {
sforce.connection.sessionId = "{!$Api.Session_ID}";
var message = new sforce.SingleEmailMessage();
message.replyTo = "varunreddypenna@gmail.com,varunrp@okstate.edu";
message.targetObjectId = "{!Opportunity.Id}";
message.templateId = "00Xj0000000J8sI";
var result = sforce.connection.sendEmail([message]);
  if(result[0].success) {
     alert("I sent the email as you requested, master.");
  } else {
     alert("I had a booboo.");
  }
}());

 

I have written a trigger on custom object Order_Item__c. This object has a custom field Shipping_Number__c. When the user enters value in Shipping_Number__c and clicks save, the contact lookup field will automatically populate with contact record which has same shipping number as the value entered by the user. 

All the contact records have the shipping customer number. Now custom object order item has a field called shipping customer number. When user enters the value in it, the trigger checks the contact record which has same number and populate the contact lookup field on order item object. The trigger is running as it is supposed to run. I am unable to achieve code coverage.

 

TRIGGER:

trigger updatelookupfield on Order_Item__c (before update, before insert)
 {


    Set<String> shippingNumbers = new Set<String>();

    for (Order_Item__c collectNumFromOrder : Trigger.new) {
        shippingNumbers.add(collectNumFromOrder.Shipping_Customer_Number__c);
    }



    List<Contact> contactList = [SELECT id, Shipping_customer_number__c FROM Contact WHERE Shipping_Customer_Number__c IN :shippingNumbers];

    Map<String, Contact> shippingNumToContactMap = new Map<String, Contact>();

    for (Contact c : contactList) {
        shippingNumToContactMap.put(c.Shipping_customer_number__c, c);
    }

    for (Order_Item__c o : Trigger.new) {

          if (o.Shipping_Customer_Number__c != null) {
            o.RSM_Shipping_Contact__c = shippingNumToContactMap.get(o.Shipping_Customer_Number__c).id;
        }
        else {
            o.RSM_Shipping_Contact__c = null;
        }

    }
    }

TEST CLASS

@isTest
public class testupdatelookupfield{

    Static testMethod void insertOrderItem()
    {   // create and insert the contact record - this part is correct
        contact c = new contact();
        c.Shipping_Customer_Number__c = '0987654';
        c.lastName = 'Surekha';

      insert c;


        // create an order item and insert it
        Order_Item__c op = new Order_Item__c();

        op.Name = 'Test Varun Order';
        op.Shipping_Customer_Number__c = '0987654';
        insert op;


        system.assertequals(op.RSM_Shipping_Contact__c,c.id);
    }
}

My trigger is working fine. Now I am trying to write a test class and I am stuck. I could not go further. Any insights in completing the test class would be helpful.

TRIGGER DESCRIPTION:
We have a custom object "OrderItem__C". This custom object has a lookup field to standard contact object. It also has a field called "Shipping_customer_number__c".

We have this same field(Shipping_customer_number__c) in contact object too. Now when the user enters a shipping customer number in the order item object, based on the value in the shipping customer number field it should auto populate the contact lookup field.

This is because each contact record has an unique shipping customer number.

TRIGGER:

trigger updatelookupfield on Order_Item__c (before update, before insert) {
    
  
    Set<String> shippingNumbers = new Set<String>();

    for (Order_Item__c collectNumFromOrder : Trigger.new) {
        shippingNumbers.add(collectNumFromOrder.Shipping_Customer_Number__c);
    }

    

    List<Contact> contactList = [SELECT id, Shipping_customer_number__c FROM Contact WHERE Shipping_Customer_Number__c IN :shippingNumbers];

    Map<String, Contact> shippingNumToContactMap = new Map<String, Contact>();

    for (Contact c : contactList) {
        shippingNumToContactMap.put(c.Shipping_customer_number__c, c);
    }

    for (Order_Item__c o : Trigger.new) {
        
          if (o.Shipping_Customer_Number__c != null) {
            o.RSM_Shipping_Contact__c = shippingNumToContactMap.get(o.Shipping_Customer_Number__c).id;
        }
        else {
            o.RSM_Shipping_Contact__c = null;
        }
           
    }
    }
TEST CLASS:
@istest

public class testupdatelookupfield
{
    Static testMethod void insertOrderItem()
    {
        contact c = new contact();
        c.Shipping_Customer_Number__c = '0987654';
        c.FirstName = 'Surekha rani';
        c.LastName = 'Penna';

        try{
            insert c;
            }catch (Exception e){
            System.debug("Error occcured");
            }



        Order_Item__c op = new Order_Item__c();

        op.Name = 'Test Varun Order';
        op.Shipping_Customer_Number__c = '0987654';
        insert op;


            list <contact> shipnum = [select id from contact where Shipping_Customer_Number__c ='0987654' ];
            System.assertEquals(1,shipnum.size());
            map <string,id> shipnummap = new map(string,id);

            for(contact ct: shipnum)
            {
                shipnummap.put(ct.Shipping_Customer_Number__c ,ct);
            }
            list <Order_Item__c > oc = [Select id,RSM_Shipping_Contact__c ,Shipping_Customer_Number__c from Order_Item__c  ];

    }
}


 
We have a custom object "OrderItem__C". This custom object has a lookup field to standard contact object. It also has a field called "Shipping_customer_number__c".

We have this same field(Shipping_customer_number__c) in contact object too. Now when the user enters a shipping customer number in the order item object, based on the value in the shipping customer number field it should auto populate the contact lookup field.

This is because each contact record has an unique shipping customer number. I am trying different ways. Any insights can be helpful for us.

Thank you.
We have a pick list field in Account object. Values of the picklist are X and Y. Now I would like to hide or restrict access to records which have picklist value as X for certain profile called Operations. So this profile users should be able to see only records with picklist value Y but not X.

I have tried different ways but could not get it. Any insights could be helpful.

Thank you.
I am trying to insert opportunities using data loader. I have mapped all the fields correctly and all my accountid and ownerid are correct. Now when I am inserting, the job is failed and I am getting the error as "insufficient access rights on cross-reference id: 001j000000E7xlw

I have the system administer profile.

Any insights would be appreciated.

Thank you.
Hello,

I have all Salesforce Account ids' in a CSV file. Now I would like to export the accounts and contacts from Salesforce org based on this. I am unable to figure out on how to achieve this. Any insights would be appreciated. 

Thank you
In my company if any user creates a case, the admin should be assigned to that case automatically. I am trying to figure out a way to do it, but I couldn't.

Any insights would be appreciated.

Thank you.
My company has production(enterprise edition) and developer sandbox. The developer sandbox is last refreshed in December. In the last 5 months many changes are made in production(eg: custom objects,buttons,etc). Now I would like to update sandbox to be an exact replica of Production. I know as ours is dev sandbox we can just have replica but not everything.

My question is if I go ahead and refresh the sandbox, will it it able to update the sandbox and have the exact replica of produciton?
Do I have to do any other to make sure that sandbox is exact replica of production.

Any insights would be helpful
Marketo is used by Marketing team in the company and the Salesforce is implemented newly. Now we want to integrate them. My concern is will this integration raise to any duplicates. If so how to eradicate them and also prevent them in the future. 

Any insights would be appreciated.
Could anyone provide me guidance on how to establish the integration with marketo and salesforce?
Any useful links would be helpful.

Thank you.
My company's Salesforce Org has everything(Data) in Production Sandox. But the salesforce best practise would be to develop in developer sandbox and to deploy in production(Correct me if I am wrong). Our requirement is to have entire data in developer sandbox too.

1)How to integrate the data between these two (production and developer)sandboxes?
2) We will be having weekly updates in production sandbox. How to keep data in sync between these two sandboxes?
Hello,

I have four record types as follows:
1) Master
2) Owner
3) Contractor
4) Partner

Master record type is for creating parent accounts. So the requirement is the users should only be able to read the Master record type records but not delete,create or modify. How can I achieve this?

Any insights would be appreciated.


Thank you.
I have created two custom objects (A and B)and a junction object(AB). i.e. Both A and B have Many to Many relationship. Now I need to insert 5000 records. How can I automatically populate the relation in Junction object. DO I have to write any trigger or Do I have to do Manually mapping the records?

 
Does anyone has idea about phone system integration with Salesforce? 
Please give me some insights into this.

Thank you.
I have a test class started, got the dummy data created and now I'm not sure where to go.

How do you write a test class for all this??  Can't SF create something that would automatically create the test class for you????
public with sharing class LicenseList { 
private final License_Numbers__c ln; 
public user currentuser{get;set;} 
public id tobeEdited{get;set;}
public decimal aTotal{get;set;}
public decimal tTotal{get;set;}
public id tobeAdded{get;set;}
public List<AccountWrapper> wrappers{get;set;}
public static Integer addCount{get;set;}
private Integer nextIdent=0;

public LicenseList(ApexPages.StandardSetController controller) { 
currentuser=new User(); 
currentuser=[Select Id, Business_Unit_new__c from User where Id=:userinfo.getuserId()]; 
this.ln = (License_Numbers__c)controller.getRecord(); 

wrappers=new List<AccountWrapper>();
for(Integer idx=0; idx<1; idx++)
{
    wrappers.add(new AccountWrapper(nextIdent++));
}

} 

//------------------------------------------------------------------------------------

public List<License_Numbers__c> lntypes16 = new List<License_Numbers__c>();

public List <License_Numbers__c> getLicenseList(){ 
lntypes16 = [select id, Name, X2016_Cost__c, Business_Unit__c, X2016_Starting_Amount__c, X2016_Subtotal__c, BMS_Code__c, License_Type__c, Monthly_Unit_Price__c, Running_License_Total__c, Org__c FROM License_Numbers__c where Business_Unit__c =:currentuser.Business_Unit_new__c AND License_Year__c = '2016' ORDER BY Order_Number__c, License_Type__c];
       

return lntypes16; 
} 


//-----------------------------------------------------------------------------
public List<License_Numbers__c> selectedTypes = new List<License_Numbers__c>();
 
public List <License_Numbers__c> getLicenseList17(){ 

selectedTypes=[select id, Name, BU_Agrees_to_Pay__c, Annualized_Running_Total__c, X2017_Cost__c, Business_Unit__c,X2017_Total_Needed__c, X2016_Starting_Amount__c, X2017_Subtotal__c, BMS_Code__c, License_Type__c, Monthly_Unit_Price__c, Org__c FROM License_Numbers__c where Business_Unit__c =:currentuser.Business_Unit_new__c AND License_Year__c = '2017' ORDER BY Order_Number__c, License_Type__c]; 
 aTotal = 0.0;
 tTotal = 0.0;       
        for(License_Numbers__c a:selectedTypes){
                aTotal = aTotal + a.X2017_Cost__c; 
                tTotal = tTotal + a.X2017_Subtotal__c;  
        }
return selectedTypes; 
} 
    public void saveRecord(){ 
    License_Numbers__c tobeupdated;
    for(License_Numbers__c temp:selectedTypes){
        if(temp.id==tobeEdited){
            tobeupdated = temp;
            
         }
     }
        update selectedTypes;
        tobeEdited = null;
    } 
//--------------------------------------------------------------------------------------------    

public List<License_Numbers__c> addlic {get; set;} 
  
public PageReference save()
{
    List<License_Numbers__c> addlic=new List<License_Numbers__c>();
    for(AccountWrapper wrap:wrappers)
    {
        addlic.add(wrap.lic);
    }
    insert addlic;
    
    return new PageReference('/apex/LicenseSummaryHomePage');
}

public class AccountWrapper
{
    public License_Numbers__c lic{get; private set;}
    public Integer ident{get; private set;}
    
    public AccountWrapper(Integer inIdent)
    {
        ident=inIdent;
        lic=new License_Numbers__c();
    }
}   

//-------------------------------------------------------------------------------------------

public SelectOption[] getSchedules() {
        return new SelectOption[] { 
            new SelectOption('Value0', '--None--'),
            new SelectOption('Value1', 'Value1'),
            new SelectOption('Value2', 'Value2'), 

  };

    }
public String discountScheduleID { get; set; }

//--------------------------------------------------------------
 Public string OutPutString{get;set;}
 Public String SelectOption;
public void displayDescription(){
if (discountScheduleID == 'Value1')
{
OutPutString = 'No Description Available' ;
}else if (discountScheduleID == 'Value2')
    {
        OutPutString = 'No Description Available' ;
}}





 
@isTest 
private class LicenseListTest{
   
   static testMethod void LicenseListTest(){
        Profile p = [SELECT Id FROM Profile WHERE Name='Community Super User' limit 1]; 
        //create a user
        UserRole r = [SELECT Id FROM userrole WHERE name = 'CM User' limit 1];
        
        User u1 = new User(LastName = 'Test Class',
                                    Username = 'CRMUser@Test.com',
                                    UserRoleId = r.Id,
                                    Email = 'CRMUser@Test.com',
                                    Alias = 'tclass',
                                    CommunityNickname = 'tclass',
                                    TimeZoneSidKey = 'Asia/Kolkata',
                                    LocaleSidKey = 'en_US',
                                    EmailEncodingKey = 'UTF-8', 
                                    ProfileId = p.Id,
                                    LanguageLocaleKey = 'en_US',
                                    Business_Unit__c = 'GCI');
        insert u1;

}
static testMethod void LicenseList_test() {

//create a license Record
        License_Numbers__c ln1 = new License_Numbers__c(
                                     Business_Unit__c = 'GCI', 
                                     X2016_Starting_Amount__c = 5, 
                                     BMS_Code__c = 'X1357', 
                                     License_Type__c = 'Service Cloud - Unlimited Edition', 
                                     Monthly_Unit_Price__c = 83.00, 
                                     Running_License_Total__c = 500, 
                                     Org__c = 'CRM Innovation', 
                                     License_Year__c = '2016');
        insert ln1;
        
         //create a license Record
        License_Numbers__c ln2 = new License_Numbers__c(
                                     Business_Unit__c = 'GCI', 
                                     X2016_Starting_Amount__c = 5, 
                                     BMS_Code__c = 'X1357', 
                                     License_Type__c = 'Analytics Cloud - Wave Analytics Platform', 
                                     Monthly_Unit_Price__c = 52.50, 
                                     Org__c = 'CRM Innovation', 
                                     License_Year__c = '2016');
        insert ln2;
}



static testMethod void LicenseList17_test() {
//create a license Record
        License_Numbers__c ln3 = new License_Numbers__c(
                                     Business_Unit__c = 'GCI', 
                                     X2016_Starting_Amount__c = 5, 
                                     BMS_Code__c = 'X1357', 
                                     License_Type__c = 'Service Cloud - Unlimited Edition', 
                                     Monthly_Unit_Price__c = 83.00, 
                                     Running_License_Total__c = 500, 
                                     Org__c = 'CRM Innovation', 
                                     License_Year__c = '2017');
        insert ln3;
        
         //create a license Record
        License_Numbers__c ln4 = new License_Numbers__c(
                                     Business_Unit__c = 'GCI', 
                                     X2016_Starting_Amount__c = 5, 
                                     BMS_Code__c = 'X1357', 
                                     License_Type__c = 'Analytics Cloud - Wave Analytics Platform', 
                                     Monthly_Unit_Price__c = 52.50, 
                                     Org__c = 'CRM Innovation', 
                                     License_Year__c = '2017');
        insert ln4;

}


}

 
  • October 12, 2016
  • Like
  • 0
I'm a SQL Server dba who got tasked with creating a Salesforce Visualforce page that renders as PDF only. I'm completely unfamiliar with apex and visualforce. I managed to make a page that works. But they want me to bold the column headings on the table that is displayed there. I tried numerous methods that I found online from "inline styles" to "static resource styles" to "facets" and none of them has any affect on the PDF output at all. Maybe I didn't correctly reference the static resource?  I'm totally lost.  Can anyone point me to some instructions or something? Is there an "Apex syntax for dummies" book? Here's the current rendition of my table although it's probably irrelevant the way it is:

<apex:pageBlockTable border="1" style="font-size:10.0pt;font-family:Arial Unicode MS" value="{!MyCustomObject__c.lses__r}" var="lse">
         <apex:column headerValue="MyColumn1" style="width:20%" value="{!lse.customfield1}" />
         <apex:column headerValue="MyColumn2" style="width:15%"  value="{!lse.customfield2}"/>
         <apex:column headerValue="MyColumn3" style="width:15%" value="{!lse.customfield3}"/>
         <apex:column headerValue="MyColumn4" style="width:15%" value="{!lse.customfield4}"/>
         <apex:column headerValue="MyColumn5" style="width:15%" value="{!lse.customfield5}"/>
         <apex:column headerValue="MyColumn6" style="width:20%" value="{!lse.customfield6}"/>
</apex:pageBlockTable>
 
Hi, I have been working on the Admin Beginning trail today and this afternoon I haven't been able to lauch the developer edition. It keeps taking me to a page where it says I have log into Salesforce first but I'm already logged in. I go ahead and log in and then I click again to launch and enter my developer login and it doesn't accept it or give any errors except that I need to log into Salesforce first. I'm a bit confused. I tried a different browser (tried both Chrome and IE) and tried clearing the browser cache. Thanks in advance for your help! 
Hi,
I am trying to update zuora subscription from apex code.
I have imported zuora api WSDL and got the classes created.
Getting below error.
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: invalid type: zObjects faultcode=fns:INVALID_TYPE faultactor=
apiZuoraCom.LoginResult zresult;
            List<apiZuoraCom.SaveResult> RetResult= new List<apiZuoraCom.SaveResult>();
            List<objectApiZuoraCom.zObject> ParaSub= new List<objectApiZuoraCom.zObject>();
            objectApiZuoraCom.zObject zobj= new objectApiZuoraCom.zObject();
            objectApiZuoraCom.subscription zsub= new objectApiZuoraCom.subscription();
            apiZuoraCom.Soap apiZuoraComsoapobj = New apiZuoraCom.Soap();
            apiZuoraComsoapobj.SessionHeader = new apiZuoraCom.SessionHeader_element();
                        
            zobj.id = '2c92c0f856300a60015630f641217d71';
            ParaSub.add(zobj);
            
            zresult = apiZuoraComsoapobj.login('user_name', 'password');
                       
            apiZuoraComsoapobj.SessionHeader.session= zresult.Session; 
            
            System.debug(apiZuoraComsoapobj.SessionHeader.session );

            RetResult = apiZuoraComsoapobj.update_x(ParaSub);

 
I have my entitlement and entitlement process without business hours.  The only place it is declared is the milestone and the Company Profile page.  Is something I need to include in my trigger to NOT make it default to the Company Profile?

Trigger
trigger CW_DefaultEntitlement on Case (Before Insert, Before Update) {
    
    List<Id> acctIds = new List<Id>();
    for(Case c: Trigger.new){
    if(String.isNotBlank(c.AccountId)){
        acctIds.add(c.AccountId);
             }
        }
        List <Entitlement> entls = [Select e.StartDate, e.Id, e.EndDate, e.AccountId From Entitlement e
                Where e.AccountId in :acctIds And e.EndDate >= Today And e.StartDate <= Today];
        if(entls.isEmpty()==false){
            for(Case c : Trigger.new){
                if(c.EntitlementId == null && c.AccountId != null){
                    for(Entitlement e:entls){
                        if(e.AccountId==c.AccountId){
                            c.EntitlementId = e.Id;
                            
                        }
                    }
                }
            }
        }
    }

 
  • July 29, 2016
  • Like
  • 0
I have 100% code coverage when I tested it in the Sandbox. When I have uploaded the same in the production using changesets, I am getting code coverage error as 53%. What might be the issue. This code for a custom button to send an email for a public group. I have all those deployed in production. Now when I am trying classes, I am getting code coverage error. I have used hardcoded values in my code. Id's of template and group. But when I deployed the email template and Group in production the values change. So is that the problem? How can I do to prevent hard coding values into the code.
 
global class memberApproval {

    webservice static boolean callApproval(Id localId) { 
                set<Id> Uid = new set<Id>();
         List<GroupMember> Lst =[Select Id, UserOrGroupId From GroupMember Where GroupId = '00G19000000YJRC'];
         if(Lst.size()>0){
         for(GroupMember g:Lst){
             Uid.add(g.UserOrGroupId);
         }

         if(Uid.size()>0){
         List<User> Lstuser = [select id,email from user where Id In:Uid];
         if(Lstuser.size()>0){

         List<String> EmailIds = new List<string>();


         for(User u:Lstuser){
         EmailIds.add(u.Email);
         }
           //New instance of a single email message
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

            // Who you are sending the email to

               mail.setToAddresses( EmailIds  );

               // The email template ID used for the email
               mail.setTemplateId('00X19000000Dm14');
               mail.setTargetObjectId(userinfo.getuserid());      
               mail.setWhatId(localId);   
               mail.setBccSender(false);
               mail.setUseSignature(false);
               mail.setReplyTo('v.reddy@thegordiangroup.com');
               mail.setSenderDisplayName('Confirmation of Order Quote');
               mail.setSaveAsActivity(false);  

            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
         }
         }
         }
        return true;               
    }
}
 
@isTest 

public with sharing class Test_Classnow {
  static testMethod void validateHelloWorld() {

    Group testGroup = new Group();
        testGroup.Name = 'testGroup';
        testGroup.DeveloperName = 'ABC';
        INSERT testGroup;

         Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User u = new User(Alias = 'standt', Email='standsdgser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='stangsgduser@testorg.com');

            insert u;


            GroupMember gm= new GroupMember(); 
            gm.GroupId=testGroup.id;
            gm.UserOrGroupId = u.id;
            insert gm;

            // insert opportunity and pass opp id instead of gm.id

      boolean result= memberApproval.callApproval(gm.id);
      system.assertequals(result,true);

  }



}



 
I have tried this code for custom button for single click email sending. Unfortunately It is not working and showing error. Could anyone tell me where I am doing wrong and correct me please.

Thank you.
location.replace('/email/author/emailauthor.jsp retURL=/{!Opportunity.Id}&p24="varunreddypenna@gmail.com,v.reddy@thegordiangroup.com"&template_id="00Xj0000000J8sI"&p3_lkid={!Opportunity.Id}&p3={!Opportunity.Name}&p26={!User.Email}&p5="penna.janareddy@gmail.com"&save=0')
User-added image
User-added image

 

I have written a trigger on custom object Order_Item__c. This object has a custom field Shipping_Number__c. When the user enters value in Shipping_Number__c and clicks save, the contact lookup field will automatically populate with contact record which has same shipping number as the value entered by the user. 

All the contact records have the shipping customer number. Now custom object order item has a field called shipping customer number. When user enters the value in it, the trigger checks the contact record which has same number and populate the contact lookup field on order item object. The trigger is running as it is supposed to run. I am unable to achieve code coverage.

 

TRIGGER:

trigger updatelookupfield on Order_Item__c (before update, before insert)
 {


    Set<String> shippingNumbers = new Set<String>();

    for (Order_Item__c collectNumFromOrder : Trigger.new) {
        shippingNumbers.add(collectNumFromOrder.Shipping_Customer_Number__c);
    }



    List<Contact> contactList = [SELECT id, Shipping_customer_number__c FROM Contact WHERE Shipping_Customer_Number__c IN :shippingNumbers];

    Map<String, Contact> shippingNumToContactMap = new Map<String, Contact>();

    for (Contact c : contactList) {
        shippingNumToContactMap.put(c.Shipping_customer_number__c, c);
    }

    for (Order_Item__c o : Trigger.new) {

          if (o.Shipping_Customer_Number__c != null) {
            o.RSM_Shipping_Contact__c = shippingNumToContactMap.get(o.Shipping_Customer_Number__c).id;
        }
        else {
            o.RSM_Shipping_Contact__c = null;
        }

    }
    }

TEST CLASS

@isTest
public class testupdatelookupfield{

    Static testMethod void insertOrderItem()
    {   // create and insert the contact record - this part is correct
        contact c = new contact();
        c.Shipping_Customer_Number__c = '0987654';
        c.lastName = 'Surekha';

      insert c;


        // create an order item and insert it
        Order_Item__c op = new Order_Item__c();

        op.Name = 'Test Varun Order';
        op.Shipping_Customer_Number__c = '0987654';
        insert op;


        system.assertequals(op.RSM_Shipping_Contact__c,c.id);
    }
}

My trigger is working fine. Now I am trying to write a test class and I am stuck. I could not go further. Any insights in completing the test class would be helpful.

TRIGGER DESCRIPTION:
We have a custom object "OrderItem__C". This custom object has a lookup field to standard contact object. It also has a field called "Shipping_customer_number__c".

We have this same field(Shipping_customer_number__c) in contact object too. Now when the user enters a shipping customer number in the order item object, based on the value in the shipping customer number field it should auto populate the contact lookup field.

This is because each contact record has an unique shipping customer number.

TRIGGER:

trigger updatelookupfield on Order_Item__c (before update, before insert) {
    
  
    Set<String> shippingNumbers = new Set<String>();

    for (Order_Item__c collectNumFromOrder : Trigger.new) {
        shippingNumbers.add(collectNumFromOrder.Shipping_Customer_Number__c);
    }

    

    List<Contact> contactList = [SELECT id, Shipping_customer_number__c FROM Contact WHERE Shipping_Customer_Number__c IN :shippingNumbers];

    Map<String, Contact> shippingNumToContactMap = new Map<String, Contact>();

    for (Contact c : contactList) {
        shippingNumToContactMap.put(c.Shipping_customer_number__c, c);
    }

    for (Order_Item__c o : Trigger.new) {
        
          if (o.Shipping_Customer_Number__c != null) {
            o.RSM_Shipping_Contact__c = shippingNumToContactMap.get(o.Shipping_Customer_Number__c).id;
        }
        else {
            o.RSM_Shipping_Contact__c = null;
        }
           
    }
    }
TEST CLASS:
@istest

public class testupdatelookupfield
{
    Static testMethod void insertOrderItem()
    {
        contact c = new contact();
        c.Shipping_Customer_Number__c = '0987654';
        c.FirstName = 'Surekha rani';
        c.LastName = 'Penna';

        try{
            insert c;
            }catch (Exception e){
            System.debug("Error occcured");
            }



        Order_Item__c op = new Order_Item__c();

        op.Name = 'Test Varun Order';
        op.Shipping_Customer_Number__c = '0987654';
        insert op;


            list <contact> shipnum = [select id from contact where Shipping_Customer_Number__c ='0987654' ];
            System.assertEquals(1,shipnum.size());
            map <string,id> shipnummap = new map(string,id);

            for(contact ct: shipnum)
            {
                shipnummap.put(ct.Shipping_Customer_Number__c ,ct);
            }
            list <Order_Item__c > oc = [Select id,RSM_Shipping_Contact__c ,Shipping_Customer_Number__c from Order_Item__c  ];

    }
}


 
We have a custom object "OrderItem__C". This custom object has a lookup field to standard contact object. It also has a field called "Shipping_customer_number__c".

We have this same field(Shipping_customer_number__c) in contact object too. Now when the user enters a shipping customer number in the order item object, based on the value in the shipping customer number field it should auto populate the contact lookup field.

This is because each contact record has an unique shipping customer number. I am trying different ways. Any insights can be helpful for us.

Thank you.
We have a pick list field in Account object. Values of the picklist are X and Y. Now I would like to hide or restrict access to records which have picklist value as X for certain profile called Operations. So this profile users should be able to see only records with picklist value Y but not X.

I have tried different ways but could not get it. Any insights could be helpful.

Thank you.
My company has production(enterprise edition) and developer sandbox. The developer sandbox is last refreshed in December. In the last 5 months many changes are made in production(eg: custom objects,buttons,etc). Now I would like to update sandbox to be an exact replica of Production. I know as ours is dev sandbox we can just have replica but not everything.

My question is if I go ahead and refresh the sandbox, will it it able to update the sandbox and have the exact replica of produciton?
Do I have to do any other to make sure that sandbox is exact replica of production.

Any insights would be helpful
Marketo is used by Marketing team in the company and the Salesforce is implemented newly. Now we want to integrate them. My concern is will this integration raise to any duplicates. If so how to eradicate them and also prevent them in the future. 

Any insights would be appreciated.
Hi, we have a requirement to integrate Salesforce with a ThirdParty Vendor using webservices.

We need to send around 300,000 Records from Salesforce to the ThirdParty vendor using their webservice.
We have a custom apex program using which we are able to call the third party web service successfully within a future method in a schedulable program. However, for a volume as high as 300k records, I am not sure how to avoid hitting the governer limits. My understanding is that, I can make 10 calls in an apex class and can call the future method 10 times, making 100 web service calls in total. This is not sufficient for 300k records. Supposing we can include multiple records in one call, we will still hit another problem. Since each call's size is restricted to 3 MB and our one SOAP call's xml size is around 20k, the maximum we can do is 150 records per call giving us the ability to send 150 X 100 = 15k records. Is there any method to avoid hitting governer limits in this scenario.

Please help me as I am new to Sales force development.