• Michael_Torchedlo
  • NEWBIE
  • 280 Points
  • Member since 2011
  • ACCO Brands

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 57
    Replies

Hi,

 

I am not sure my Subject is correctly write or not.But I faced issue on something like this,

 

Example I have one object named Employee with contains attribute such  InternalID ,ExternalID, name , age

 

I need to retrieve the data where InternalId = ExternalID something like below

 

select Name, Age__c  from Employee__c where InternalID__c = ExternalID__c 

 

 

I knew in Oracle we can do something like this, but I m not sure in SFDC can we do that?Usually if there requirement to do that, what is the best way to do it?

I wrote a whole Task trigger around updating a field Last Activity by Account Owner.  Tested fine, and deployed, and I'm noticing it's not always working.  I've tracked the issue to the SOQL query (I think):

SELECT id, (SELECT id, ActivityDate, AccountId FROM Tasks WHERE Owner_Matches_Account_Owner__c = true AND IsClosed = true ORDER BY ActivityDate DESC LIMIT 1) FROM Account	WHERE id IN :dates.keySet()

 I know the list of ID's coming into the query is correct, but it looks like most times there are 0 results.

 

Based on the Task documentation (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_task.htm), it seems like this is set at some point (I made my trigger an AFTER to be sure):

AccountID: ID of the related Account.This is the account of WhatId if it exists, otherwise it’s the account of WhoId if it exists, otherwise it’s set to null. 

 

So far the Contacts are related to Accounts so I don't believe that's the issue.

 

Any thoughts?  I'm so stuck on this I'm going to have to comment the whole thing out and just do the update manually every day.  Argh.  PS - I originally got help writing this query from these boards here: http://boards.developerforce.com/t5/Apex-Code-Development/Select-newest-Task-from-Map-of-AcctId-s/m-p/643891#M119210

 

Edit: So far, what I've found is that the salesforce BCC logging email tasks work, and tasks that users add themselves do not work.  Neither is attached directly to the Account thru the Related To - only the Contact is filled in.

Below is a section of a test class that I'm modifying due to a trigger change.  It passes all tests in the sandbox, but when trying to deploy I get an error at the first assert stating it can't find the sample work order.  I'm thinking this is due to a record not being created earlier on, but I can't see the error in the debug log.  My question is how to set/use the debug log correctly so that it shows the error and I can fix it.

 

Thank you for any help.

 

static testMethod void TestUpdateProductCodeTrigger()
     {  
     	Product2 part = [Select Id, Name From Product2 where Family = 'Pumps' and Site__c = 'E' and IsActive = true and status__c = 'A' limit 1];                       
        System.debug('part is: ' +part.Name);
        
		              
        RecordType rtBusinessAcc1 = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'Account'
                                AND Name = 'Business Account'];
                                
        RecordType rtConsumerAcc1 = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'Account'
                                AND Name = 'Consumer Account'];                        
                                

        Account ac1 = new Account (Name='test test',Email__c = 'test@test.com', RecordTypeId = rtBusinessAcc1.Id, Phone='4081234567', Type = 'SLS');
        try{
        insert ac1;

        }
               catch (Exception e) {
                system.debug('business account insert error is '+e.getMessage());
                }
                
        Account ac = new Account (
        		FirstName = 'Test',
        		LastName = 'Name',
        		Phone = '9195551212',
        		PersonMailingStreet = '123 Test',
        		PersonMailingCity = 'sanford',
        		PersonMailingState = 'NC',
        		PersonMailingCountry = 'US',
        		Pump_Seal_Test_Site__c = False,
        		RecordTypeId = rtConsumerAcc1.Id
        		);
        try{
        insert ac;
        }
               catch (Exception e) {
                system.debug('person account insert error is '+e.getMessage());
                } 
        System.debug('The person account name is: ' +ac.Name);       
        Contact ct = [Select Id, FirstName, LastName, accountid From Contact Where accountid = : ac.Id ];
        System.debug('The contact name is: ' +ct.FirstName  +ct.LastName);
        
        Case cs1 = new Case (
                    AccountId = ac.Id, 
                    ContactId = ct.Id, 
                    Status = 'New',
                    Origin = 'Email',
                    Type = 'Service',
                    Description = 'Test',
                    Product_Number__c = Part.Id,
                    Product_Model__c = 'Pumps',
                    Problem_Code__c = 'AC01=test',
                    Installation_Date__c = System.today()- 30
                    );
        insert cs1;
		System.debug('The case number is: ' +cs1.CaseNumber);
		
        Case cs2 = new Case (
                    AccountId = ac.Id, 
                    ContactId = ct.Id, 
                    Status = 'New',
                    Origin = 'Email',
                    Type = 'Service',
                    Description = 'Test',
                    Product_Number__c = Part.Id,
                    Installation_Date__c = System.today()
                    );
        insert cs2;
		System.debug('The case number is: ' +cs2.CaseNumber);
		
        
		
        // Invoking the Method "SVMX_GetProductCode()"
        String strProdCodeSP1 = SVMX_ProductInfo.SVMX_GetProductCode(Part.Id);
        
        RecordType rt = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'SVMXC__Service_Order__c'
                                AND Name = 'Regular'];
        RecordType rt1 = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'SVMXC__Service_Order__c'
                                AND Name = 'Fast Track'];                        
        
        //Select warranty admin user
		        
        RecordType rType = [SELECT Id from RecordType where SObjectType = 'SVMXC__Service_Group__c' and Name = 'Setup'];
          
        User usr = [Select Id, Name from User Where Profile.Name = 'Warranty Administrator' and IsActive = true limit 1 ];
        
        System.debug('The user name is: ' +usr.Name);
        
          
		SVMXC__Service_Group__c sg = new SVMXC__Service_Group__c(Warranty_Station_Email__c = 'abc@xyz.com', 
																	SVMXC__Active__c = true,
																	Equipment__c = 'a,b',
																	QAD_Vend_Code__c = 'ZZ125487', 
																	QADCode__c = 'ZZ000000', 
																	PolicyExp__c = System.today()+ 7, 
																	Name = 'testsvg', 
																	Insurance_number__c = '4517744', 
																	AppDate__c = System.today(), Region__c = 'Arizona', SVMXC__Group_Type__c = 'Partner', Phone__c = '(919) 566-8899',
																	Address__c = '123 main', City__c = 'sanford', State__c = 'nc', Zip__c = '27330', Country_Code__c = 'US',
																	ABC__c = 'A', RecordTypeId = rType.Id, Sales_Rep__c = ac1.Id, Service_Rep__c = ac1.Id, 
																	Admin__c = usr.Id);
		try{
        insert sg;
        }
               catch (Exception e) {
                system.debug('service team insert error is '+e.getMessage());
                }
		//insert sg;
		System.debug('The team name is: ' +sg.Name);
        
		System.runAs(usr)//run as a warranty admin profile user
        {
        // Create WO with Product                 
        SVMXC__Service_Order__c  SampleWorkOrder1 = new SVMXC__Service_Order__c (
        RecordTypeId = rt.Id,
		SVMXC__Case__c = cs1.Id ,
        SVMXC__Company__c  = ac.Id , 
        SVMXC__Contact__c = ct.Id,
        Product__c = Part.Id,
        SVMXC__Service_Group__c = sg.Id,
		SVMXC__Priority__c = 'Medium',
		SVMXC__Order_Type__c = 'Field Service',
		Repair_Date__c = System.today(),
        SVMXC__Order_Status__c ='Processing Error',
        Reason_For_Denial__c = 'Test denial'
        );
         
        try{
        insert SampleWorkOrder1;
        }
               catch (Exception e) {
                system.debug('sample work order 1 insert error is '+e.getMessage());
                }     
        System.debug('The work order number is: ' +SampleWorkOrder1.Name);
        
        //assert that the processed date and processed by fields are set correctly on insert
        SVMXC__Service_Order__c wo = [Select Id, Processed_Date__c, Processed_By__c From SVMXC__Service_Order__c Where Id = :SampleWorkOrder1.Id];
        System.assertEquals(wo.Processed_Date__c, System.today());
        System.assertEquals(wo.Processed_By__c, UserInfo.getName());
        
                        
        SVMXC__Service_Order__c  SampleWorkOrder2 = [SELECT Id ,Product__c, SVMXC__Order_Status__c, Reason_For_Denial__c FROM SVMXC__Service_Order__c where Id= :SampleWorkOrder1.Id ];
        SampleWorkOrder2.Product__c = Part.Id;        
        SampleWorkOrder2.SVMXC__Service_Group__c =sg.Id;
        SampleWorkOrder2.SVMXC__Company__c  = ac.Id;
        SampleWorkOrder2.SVMXC__Order_Status__c = 'Warranty Denied';
        SampleWorkOrder2.Reason_For_Denial__c = 'Test denial';
        try{
        update SampleWorkOrder2;
        }
               catch (Exception e) {
                system.debug('svol insert error is '+e.getMessage());
                }
        //assert that the processed date and processed by fields are set correctly on update
        SVMXC__Service_Order__c wo2 = [Select Id, Processed_Date__c, Processed_By__c From SVMXC__Service_Order__c Where Id = :SampleWorkOrder2.Id];
        System.assertEquals(wo.Processed_Date__c, System.today());
        System.assertEquals(wo.Processed_By__c, UserInfo.getName()); 
        
        SampleWorkOrder2.Amount__c = 0;
        SampleWorkOrder2.SVMXC__Order_Status__c = 'Warranty Processed';
        
        try{
        	update SampleWorkOrder2;
        }
        catch (Exception e) {
                System.Assert(e.getMessage().contains ('A dollar amount is required'));
                }
        
                                
        SVMXC__Service_Order__c  SampleWorkOrder3 = new SVMXC__Service_Order__c (
        SVMXC__Case__c = cs2.Id ,
        SVMXC__Contact__c =ct.Id,
        Product__c = Part.Id,
        SVMXC__Company__c  = ac.Id,
        Product_Model__c = 'Automation',
        Installation_Date__c = System.today(),
        SVMXC__Order_Status__c = 'Open',
        SVMXC__Priority__c = 'Medium',
        SVMXC__Order_Type__c = 'Field Service',
        Street__c = '123 test street',
        City__c = 'test city',
        State__c = 'test state',
        CaseProductGroup__c = 'Filter',
        Case_Problem_Code__c = 'FP93: WS STOCKING',
        SVMXC__Problem_Description__c = 'test description',
        SVMXC__Service_Group__c =sg.Id,
        RecordTypeId = rt1.Id); 
        try{
        insert SampleWorkOrder3;
        }
               catch (Exception e) {
                system.debug('svol insert error is '+e.getMessage());
                }
        
        SVMXC__Service_Order__c  SampleWorkOrder4 =  [SELECT Id ,Product__c FROM SVMXC__Service_Order__c where Id= :SampleWorkOrder1.Id ];
        SampleWorkOrder2.Product__c = Part.Id;
        SampleWorkOrder2.SVMXC__Service_Group__c =sg.Id;
        SampleWorkOrder2.SVMXC__Company__c  = ac.Id;
        try{
        update SampleWorkOrder4;
        }
               catch (Exception e) {
                system.debug('svol insert error is '+e.getMessage());
                } 
        }                  
     }

 

  • July 23, 2013
  • Like
  • 0

What I am trying to do is update a custom date field.  I want to put the date of the last activity that does not contain "Act-On Email" into the field "Last_Activity_by_Account_Owner__c".

 

The trigger works great until I do a mass update to trigger the trigger on previous tasks, but then I run into System.LimitException: Too many SOQL queries: 101.   I believe it is because I have a query inside the for loop, but I am new to Triggers and I dont know how to fix it.

 

My code:

 

trigger LastActDate2 on Task (after insert, after update) {
    
    
    //To do - If the subject of a completed task does not contain "Act-On Email", put the date of the completed task in the
    //"Last_Activity_by_Account_Owner__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();


//For every task, add it's related to account ID to the set
 for (Task t: Trigger.new){
    if (t.accountID != NULL){
      acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
      Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID,Account_Owner_Role__c, Last_Activity_by_Account_Owner__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line contains "Act-On Email", the account record owner's role matches the task record owner's role, and the task has been marked as completed
//Check to see if the Last_Activity_by_Account_Owner__c field is current compared with the latest completed activity    
    If (((!t.subject.contains('Act-On Email'))&&acctMap.get(t.accountID).Account_Owner_Role__c == t.Task_Owner_Role__c && (t.Status == 'Completed')) &&
    (acctMap.get(t.accountID).Last_Activity_by_Account_Owner__c  < t.ActivityDate || acctMap.get(t.accountID).Last_Activity_by_Account_Owner__c  ==null )){
//Update the Last_Activity_by_Account_Owner__c field on the account object with the task's end date  
          acctrec.Last_Activity_by_Account_Owner__c  = t.ActivityDate;
    
      }
    update acctRec;
  }
  }
  }

I'm learning apex so have set myself some challenges and I'm trying to get some best practice help.  I have a trigger (important snippets below) which passes the inserted Slots__c record(s) into my class. That's all I want the trigger to do really as I understand that's the best way to do things.

 

trigger InsertAvailableServices on Slots__c (before insert, before update, after insert, after update) {
    if(trigger.isAfter){
        if(trigger.isInsert){
            OpeningInsertAfter myInsertAfter = new OpeningInsertAfter(Trigger.new);
        }
    }
}

In my class, I want to get the information from the inserted Slot__c record so that I can use this within another SOQL query against an un-related object.  I can get all this to work in a trigger but now it's time to learn about classes and doing things correctly.

 

1.  I'm sure there a better way to store the field values from the inserted Slot__c record, rather than having a load of public variables like my logic below? e.g. public string AccountId {get; set;}

 

//constructor accepting a list of myObjects
    public OpeningInsertAfter(Slots__c[] myOpenings){
		for (Slots__c opp:myOpenings){
			OpeningId = opp.Id;
			OpeningDuration = opp.Duration_mins__c;
			Discount = opp.Discount__c;
			AccountId = opp.Account__c;
			StartDate = opp.Start_Time__c;
		}	          
    }       

 2. My next challenge is constructing the rest of the class.  How do I call this method so that it exectutes? It's purpose is to build a list of available_treatment__c records.

 

    public OpeningInsertAfter() { 
		TheServices = [select Id, Name, Account__c, Duration_Int__c, Price__c 
		from Treatment__c where Account__c =: AccountId and Duration_Int__c <=: OpeningDuration];
    		System.Debug('Treatment List' + TheServices);
    		for (Treatment__c service : TheServices) {
	              {
	                   availableServices.add(new Available_Treatments__c
	                   (Slot__c = OpeningId, treatment__c = service.id, Start_Time__c = StartDate,
	                   Duration_mins__c = service.Duration_Int__c,
	                   Internet_Price__c = service.Price__c - ((service.Price__c * Discount) / 100),
	                   Treatments_for_Slot__c = ((OpeningDuration / service.Duration_Int__c).round(roundingMode.DOWN))));          
	               }
	         }
		Insert availableServices; 
    } 

A chopped down version of my current class is as follows:

 

public class OpeningInsertAfter {
//my public variables here
public List<Treatment__c> TheServices {get; set;}

 public OpeningInsertAfter() { 
   //this goes off and builds a list of records to insert into available_treatments__c object
//I use the details from the inserted Slots__c record here } public OpeningInsertAfter(Slots__c[] myOpenings){ for (Slots__c opp:myOpenings){ //grabs all the details from inserted record } }

 

Hello and Hold on to your hats folks I got a doosie! 

 

So the long and short is I am trying to implement a custom home page for my customer portal users.  This has 2 buttons, submit a case to support and submitt a case to dev.  I am using this class as a controller but I am not getting any coverage.

 

public class Home_Page_testsfdc {

    public Home_Page_testsfdc() {

    }

public Home_Page_testsfdc(ApexPages.StandardController controller) 
  {
  }
  
  public pagereference redirect1()
 {   
  
   pagereference p=new pagereference('https://cs8.salesforce.com/500/e?retURL=%2Fhome%2Fhome.jsp%3Fsdtd%3D1&#38;RecordType=012C0000000GGL3&#38;ent=Case');
  return p;
}
public pagereference redirect2()
 {   
  
   pagereference p=new pagereference('https://cs8.salesforce.com/500/e?retURL=%2Fhome%2Fhome.jsp%3Fsdtd%3D1&#38;RecordType=012C0000000GGL3&#38;ent=Case');
  return p;
}

}

 

The question then is, do I need to cover this code in the class itself or would I need to create a test class to cover this bad boy?  

 

 

Kev

 

I am needing to automatically create a quote record and attach it to a related quotelineitem. The steps the user will do for the automation is the following:

 

1. User will go to the quote record.

2. In the quote line item related list, the user will check the box next to the chosen quote line item.
3. User will click "New Quote" button in the quote line item related list section of the original quote.
4. The new quote will be connected to the chosen quote line item through the lookup field "Base Product."

 

Below is the apex class that creates the quot, but I cannot connect the quote to the chosen quote line item. Below is my apex class:

 

public class displayproductoptionsv6{

    public QuoteLineItem qlit;
    public String getquotelineitem(){return null;}
    public String getproduct2(){return null;}
    public String pname {get;set;}
    public Id o {get;set;}
    public List<Quote> q {get;set;}
    public List<cProduct> pList {get; set;}
    public List<cProduct> p2List {get; set;}
    public List<PriceBookEntry> spList {get; set;}
    public List<cProduct> cpsel{get; set;}
    public List<string> selectedproductid = new list<string>();
    ApexPages.StandardController controller;
    public displayproductoptionsv6(ApexPages.StandardController c){
    
        qlit = [select id, Quote.name, pricebookentryid, pricebookentry.product2id, Quote.opportunityid from QuoteLineItem where id =: ApexPages.currentpage().getParameters().get('qli')];
    system.debug('*****TEST-1**********'+qlit.id);
    
         q = [select id from Quote where id =: ApexPages.currentpage().getParameters().get('quoteid')];
    List<QuoteLineItem> qbase = [select id, quote.name, quantity, quote.Opportunity.Name, Pricebookentry.Product2.name, Pricebookentry.Pricebook2id, 
                                currencyisocode, Product_Base_Option__c from QuoteLineItem where id =: qlit.id];
    
    for(QuoteLineItem ql :qbase){
        pname = qbase[0].Pricebookentry.Product2.name;
    } 

 pList = new List<cProduct>();
    List<Pricebookentry> prbase  = [select id, name, Product2.Product_Base_Option__c,product2.productcode,
                                    unitprice, product2.description, pricebook2id, product2.mfg_cost_us__c from 
                                   Pricebookentry where pricebook2id =: qbase[0].pricebookentry.pricebook2id
                                   and product2.Product_Base_Option__c like: '%Option%'
                                   and product2.Product_Base_Option__c like: '%'+qbase[0].Product_Base_Option__c+'%'order by product2.name asc];

            for(Pricebookentry pbase : prbase){
                
                cProduct c1 = new cProduct(pbase);
                c1.selected = false;
                plist.add(c1);
                }
        system.debug('*****SFDC-TEST-1**********'+pList);
         if(Test.isRunningTest())
         { getquotelineitem();
            getproduct2();

             }
   }             

    public List<cProduct> getresults()
    { 
      System.debug('$$$$$$$$'+pList);
      return pList; 
    }
  
    public pageReference processSelected(){

        List<Pricebookentry> selectedProduct = new List<Pricebookentry>();
        List<Pricebookentry> base = [select id from pricebookentry where id =: qlit.pricebookentryid];
       System.debug('%%%%%%%%%%%%'+getresults());
       System.debug('%%%%%%%%%%%%:::'+ApexPages.currentPage().getParameters().get('id'));

        for(cProduct cCon : getresults()) {

        System.debug('#####'+cCon.selected);
            if(cCon.selected == true) {
                selectedProduct.add(cCon.con);         
                 System.debug('%%%%%%%%%%%%'+selectedProduct);    
                 System.debug('%%%%%%%%%%%%'+selectedProduct.size());    
            }
        }

    cpsel = new List<cProduct>();    
  if(test.isRunningTest()){
   getresults();
   
    }          
        system.debug('*****SFDC-TEST-3**********'+selectedProduct);

       System.debug('These are the selected Products...');
       System.debug('##########SelectedProduct:'+SelectedProduct);

        for(PricebookEntry cCon : SelectedProduct ) {
            system.debug('#####cCon'+cCon);
            selectedproductid.add(cCon.id);
        }
                system.debug('######********########'+selectedproductid);
                system.debug('######********########'+selectedproductid.size());

        for(PricebookEntry cCon : base) {
            system.debug('#####cCon'+cCon);
            selectedproductid.add(cCon.id);
        }

return null;
}

    public List<PricebookEntry> getchosen()
    { 
      System.debug('$$$$$$$$'+splist);


     splist = [select id, PriceBookEntry.Product2.name, product2.mfg_cost_us__c,
                                       product2.quantity__c, product2.item__c, unitprice from Pricebookentry
                                       where id in: selectedproductid]; 
      return splist; 

    }
    
    /* Wrapper class to contain product record and a boolean flag */
public class cProduct{
public Pricebookentry con {get; set;}
public Pricebookentry scon {get; set;}
public Boolean selected {get; set;}

public cProduct (Pricebookentry c)
{
     con = c;
     selected = false;
      }
}

/* end of Wrapper class */
public PageReference Save() {

      List<quotelineitem> qli = [select id, pricebookentry.product2.name, quote.pricebook2id, 
          quote.Opportunity.SFDC_for_Quote__c, quote.Opportunityid from quotelineitem where id =:qlit.id];
      
      id cqrt = [select id from recordtype where name = 'AutoConfig Quote'].id;
      
      Quote qt = new Quote();
          qt.Opportunityid = qli[0].quote.Opportunityid;
          qt.pricebook2id = qli[0].quote.pricebook2id;
          qt.name = qli[0].pricebookentry.product2.name + ' - ' + qli[0].quote.Opportunity.SFDC_for_Quote__c + ' - Configuration';
          qt.Base_Product__c = qli[0].id;
          qt.recordtypeid = cqrt;
      
      database.insert(qt);
      
   List<Pricebookentry> pbe = [select id, PriceBookEntry.Product2.name, product2.mfg_cost_us__c,
                                       product2.quantity__c, product2.item__c, unitprice from Pricebookentry
                                       where id =: qli[0].id]; 
         
    List<QuoteLineItem> ql = new list<QuoteLineItem>();
    
    for(QuoteLineItem qu : ql){
        
        qu.pricebookentryid = pbe[0].product2id;
        qu.quoteid = qt.id;
        qu.cost__c =splist[0].product2.mfg_cost_us__c;
        qu.quantity = splist[0].product2.quantity__c;
        qu.item__c = splist[0].product2.item__c; 
        qu.unitprice = splist[0].unitprice;
        
     insert qu;
    }
    

    PageReference pageRef = new PageReference('/' + qlit.id);
    
     return pageref;
    }
   public PageReference CancelPage() {
           
        return (new ApexPages.StandardController(qlit)).view();
    }


}

 

I wanna call the standard 'EmailQuote()' method of quotes in my custom visualforce page. 

 

VF Page:

<apex:page standardController="quote" extensions="quoteSample">

<apex:form >
<apex:pageBlock >
    <apex:outputfield value="{!quote.Name}"/>
    <apex:commandButton action="{!EmailQuote}" value="Email"/>
    
    </apex:pageBlock>
</apex:form>

</apex:page>

 Class:

 

 

public with sharing class quoteSample {    
public quote q;        

public quoteSample(ApexPages.StandardController controller) {
    this.q = (quote)controller.getRecord();    }  

public pagereference EmailQuote(){
        EmailQuote();        
        PageReference newPage = New PageReference('get('id'));
newPage.setRedirect(true); return newPage; } }

 

Error:

 

Maximum stack depth reached: 1001

Error is in expression '{!EmailQuote}' in component <apex:page> in page quotesample

 

 

An unexpected error has occurred. Your development organization has been notified.

 

Does anyone have a way to make a Long Text Area or Rich Text Area field unique?  We have a custom field on a custom object that is slightly longer than a regular text field but I still want to block duplicates.
I've been reading through the documentation about using the sforce.one javascript library but I can't seem to get a simple hyperlink or output link to properly work in Salesforce1.  If anyone in the community can please clarify where my error is, it is much appreciated.

The page renders properly in the mobile app, but the links do nothing (no error message, no screen change).

As a novice, I thought it may be just a syntax problem, so I tried several variations below.
 
<apex:page docType="html-5.0" showheader="false" sidebar="false" > 
    <div style="width:100%;" >
    <apex:form rendered="true" id="theform" >
    
    <apex:outputLink value="javascript:sforce.one.navigateToSObject(001e000000Ysn5I);" >
          <apex:outputText value="LINK 1" />
    </apex:outputLink><br/><br/>
    
    <apex:outputLink value="javascript:sforce.one.navigateToSObject('001e000000Ysn5I');"  >
          <apex:outputText value="LINK 2" />
    </apex:outputLink><br/><br/>

    <apex:outputLink value="javascript:sforce.one.navigateToURL('/001e000000Ysn5I');"  >
          <apex:outputText value="LINK 3" />
    </apex:outputLink><br/><br/>
    
    <apex:outputLink value="javascript:sforce.one.navigateToURL(/001e000000Ysn5I);"  >
          <apex:outputText value="LINK 4" />
    </apex:outputLink><br/><br/>        
        
    </apex:form>
    </div>
</apex:page>


 
In the Summer '14 release notes (see link), the user profile page layout can be customized for Salesforce1, but only for Android devices. Does anyone have a workaround for iOS devices, or is there any timeline for when it might become available?

http://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_mobile_salesforce1_newfeat_profile_layout.htm
Does anyone have a way to make a Long Text Area or Rich Text Area field unique?  We have a custom field on a custom object that is slightly longer than a regular text field but I still want to block duplicates.
I've been reading through the documentation about using the sforce.one javascript library but I can't seem to get a simple hyperlink or output link to properly work in Salesforce1.  If anyone in the community can please clarify where my error is, it is much appreciated.

The page renders properly in the mobile app, but the links do nothing (no error message, no screen change).

As a novice, I thought it may be just a syntax problem, so I tried several variations below.
 
<apex:page docType="html-5.0" showheader="false" sidebar="false" > 
    <div style="width:100%;" >
    <apex:form rendered="true" id="theform" >
    
    <apex:outputLink value="javascript:sforce.one.navigateToSObject(001e000000Ysn5I);" >
          <apex:outputText value="LINK 1" />
    </apex:outputLink><br/><br/>
    
    <apex:outputLink value="javascript:sforce.one.navigateToSObject('001e000000Ysn5I');"  >
          <apex:outputText value="LINK 2" />
    </apex:outputLink><br/><br/>

    <apex:outputLink value="javascript:sforce.one.navigateToURL('/001e000000Ysn5I');"  >
          <apex:outputText value="LINK 3" />
    </apex:outputLink><br/><br/>
    
    <apex:outputLink value="javascript:sforce.one.navigateToURL(/001e000000Ysn5I);"  >
          <apex:outputText value="LINK 4" />
    </apex:outputLink><br/><br/>        
        
    </apex:form>
    </div>
</apex:page>


 
In the Summer '14 release notes (see link), the user profile page layout can be customized for Salesforce1, but only for Android devices. Does anyone have a workaround for iOS devices, or is there any timeline for when it might become available?

http://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_mobile_salesforce1_newfeat_profile_layout.htm

I have created three custom fields for my product line items - 'StartDate', 'Duration' and 'EndDate'. I have then created the same fields in my Quote line items as I need them to appear on my quotes. I am brand new to apex and its taking a lot of reading and patience to figure out where to start. I need to get this sorted my next week or I'll be in trouble with my boss. 

 

What my custom fields do: The start date is self explanatory, the duration is the number of months in one of our Support contracts, the duration is entered after the start date, which then calculates the end date. For example;

Start date 01/01/2014 - Duration 12 (hit save) End Date calculates: 01/01/2015
 
When I hit new quote, and the information from my product line items is copied into my Quote Line Items, I need my custom information to do the same. Does anyone know how I can go about this. Below is what I have started think I am totally way off. Help! 
 
trigger AutopopulateStartDate on QuoteLineItems (after insert, after update) {
//. Create a container for the products that need start dates inserted to them
Set updatedStartDate = new
//If this is an insert, I want the date to be inserted to the correct product
if (trigger.isInsert) {
for (StartDate s : trigger.new) {
productstartdate.add;
 
 
 
 

Hi guys,

 

I'm trying to understand what to expect from Force.com, regarding major versions' upgrades. In your expeerience, how seamless are the upgrades to your Force.com?

 

  1. Are there many breaking changes?
  2. When your code is affected by these breaking changes, what are your options? Redo the code? What time window do you have?
  3. In your experience, how much time does a Force.com major version upgrade consumes you, in terms or redoing/ verifying the code?
  4. And, in terms of testing your applications, to make sure the functionally hasn't broken? Does it break often?
  5. What is Force.com policy, regarding upgrades? They warn about the updates how much time ahead? DO we have a specific time frame to do these upgrades? What happens if you don't upgrade?
  6. Does your organization accept the upgrades well (the downatime, the Business Units having to participate in the tests, etc.)?

 

I'm trying to assess how much time should I schedule in future major versions upgrades...

Please answer what you can (even if you can't answer everything).

 

Thanks for everyone's help.

Hi,

 

I am not sure my Subject is correctly write or not.But I faced issue on something like this,

 

Example I have one object named Employee with contains attribute such  InternalID ,ExternalID, name , age

 

I need to retrieve the data where InternalId = ExternalID something like below

 

select Name, Age__c  from Employee__c where InternalID__c = ExternalID__c 

 

 

I knew in Oracle we can do something like this, but I m not sure in SFDC can we do that?Usually if there requirement to do that, what is the best way to do it?

I wrote a whole Task trigger around updating a field Last Activity by Account Owner.  Tested fine, and deployed, and I'm noticing it's not always working.  I've tracked the issue to the SOQL query (I think):

SELECT id, (SELECT id, ActivityDate, AccountId FROM Tasks WHERE Owner_Matches_Account_Owner__c = true AND IsClosed = true ORDER BY ActivityDate DESC LIMIT 1) FROM Account	WHERE id IN :dates.keySet()

 I know the list of ID's coming into the query is correct, but it looks like most times there are 0 results.

 

Based on the Task documentation (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_task.htm), it seems like this is set at some point (I made my trigger an AFTER to be sure):

AccountID: ID of the related Account.This is the account of WhatId if it exists, otherwise it’s the account of WhoId if it exists, otherwise it’s set to null. 

 

So far the Contacts are related to Accounts so I don't believe that's the issue.

 

Any thoughts?  I'm so stuck on this I'm going to have to comment the whole thing out and just do the update manually every day.  Argh.  PS - I originally got help writing this query from these boards here: http://boards.developerforce.com/t5/Apex-Code-Development/Select-newest-Task-from-Map-of-AcctId-s/m-p/643891#M119210

 

Edit: So far, what I've found is that the salesforce BCC logging email tasks work, and tasks that users add themselves do not work.  Neither is attached directly to the Account thru the Related To - only the Contact is filled in.

Below is a section of a test class that I'm modifying due to a trigger change.  It passes all tests in the sandbox, but when trying to deploy I get an error at the first assert stating it can't find the sample work order.  I'm thinking this is due to a record not being created earlier on, but I can't see the error in the debug log.  My question is how to set/use the debug log correctly so that it shows the error and I can fix it.

 

Thank you for any help.

 

static testMethod void TestUpdateProductCodeTrigger()
     {  
     	Product2 part = [Select Id, Name From Product2 where Family = 'Pumps' and Site__c = 'E' and IsActive = true and status__c = 'A' limit 1];                       
        System.debug('part is: ' +part.Name);
        
		              
        RecordType rtBusinessAcc1 = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'Account'
                                AND Name = 'Business Account'];
                                
        RecordType rtConsumerAcc1 = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'Account'
                                AND Name = 'Consumer Account'];                        
                                

        Account ac1 = new Account (Name='test test',Email__c = 'test@test.com', RecordTypeId = rtBusinessAcc1.Id, Phone='4081234567', Type = 'SLS');
        try{
        insert ac1;

        }
               catch (Exception e) {
                system.debug('business account insert error is '+e.getMessage());
                }
                
        Account ac = new Account (
        		FirstName = 'Test',
        		LastName = 'Name',
        		Phone = '9195551212',
        		PersonMailingStreet = '123 Test',
        		PersonMailingCity = 'sanford',
        		PersonMailingState = 'NC',
        		PersonMailingCountry = 'US',
        		Pump_Seal_Test_Site__c = False,
        		RecordTypeId = rtConsumerAcc1.Id
        		);
        try{
        insert ac;
        }
               catch (Exception e) {
                system.debug('person account insert error is '+e.getMessage());
                } 
        System.debug('The person account name is: ' +ac.Name);       
        Contact ct = [Select Id, FirstName, LastName, accountid From Contact Where accountid = : ac.Id ];
        System.debug('The contact name is: ' +ct.FirstName  +ct.LastName);
        
        Case cs1 = new Case (
                    AccountId = ac.Id, 
                    ContactId = ct.Id, 
                    Status = 'New',
                    Origin = 'Email',
                    Type = 'Service',
                    Description = 'Test',
                    Product_Number__c = Part.Id,
                    Product_Model__c = 'Pumps',
                    Problem_Code__c = 'AC01=test',
                    Installation_Date__c = System.today()- 30
                    );
        insert cs1;
		System.debug('The case number is: ' +cs1.CaseNumber);
		
        Case cs2 = new Case (
                    AccountId = ac.Id, 
                    ContactId = ct.Id, 
                    Status = 'New',
                    Origin = 'Email',
                    Type = 'Service',
                    Description = 'Test',
                    Product_Number__c = Part.Id,
                    Installation_Date__c = System.today()
                    );
        insert cs2;
		System.debug('The case number is: ' +cs2.CaseNumber);
		
        
		
        // Invoking the Method "SVMX_GetProductCode()"
        String strProdCodeSP1 = SVMX_ProductInfo.SVMX_GetProductCode(Part.Id);
        
        RecordType rt = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'SVMXC__Service_Order__c'
                                AND Name = 'Regular'];
        RecordType rt1 = [SELECT Id FROM RecordType 
                                WHERE SObjectType = 'SVMXC__Service_Order__c'
                                AND Name = 'Fast Track'];                        
        
        //Select warranty admin user
		        
        RecordType rType = [SELECT Id from RecordType where SObjectType = 'SVMXC__Service_Group__c' and Name = 'Setup'];
          
        User usr = [Select Id, Name from User Where Profile.Name = 'Warranty Administrator' and IsActive = true limit 1 ];
        
        System.debug('The user name is: ' +usr.Name);
        
          
		SVMXC__Service_Group__c sg = new SVMXC__Service_Group__c(Warranty_Station_Email__c = 'abc@xyz.com', 
																	SVMXC__Active__c = true,
																	Equipment__c = 'a,b',
																	QAD_Vend_Code__c = 'ZZ125487', 
																	QADCode__c = 'ZZ000000', 
																	PolicyExp__c = System.today()+ 7, 
																	Name = 'testsvg', 
																	Insurance_number__c = '4517744', 
																	AppDate__c = System.today(), Region__c = 'Arizona', SVMXC__Group_Type__c = 'Partner', Phone__c = '(919) 566-8899',
																	Address__c = '123 main', City__c = 'sanford', State__c = 'nc', Zip__c = '27330', Country_Code__c = 'US',
																	ABC__c = 'A', RecordTypeId = rType.Id, Sales_Rep__c = ac1.Id, Service_Rep__c = ac1.Id, 
																	Admin__c = usr.Id);
		try{
        insert sg;
        }
               catch (Exception e) {
                system.debug('service team insert error is '+e.getMessage());
                }
		//insert sg;
		System.debug('The team name is: ' +sg.Name);
        
		System.runAs(usr)//run as a warranty admin profile user
        {
        // Create WO with Product                 
        SVMXC__Service_Order__c  SampleWorkOrder1 = new SVMXC__Service_Order__c (
        RecordTypeId = rt.Id,
		SVMXC__Case__c = cs1.Id ,
        SVMXC__Company__c  = ac.Id , 
        SVMXC__Contact__c = ct.Id,
        Product__c = Part.Id,
        SVMXC__Service_Group__c = sg.Id,
		SVMXC__Priority__c = 'Medium',
		SVMXC__Order_Type__c = 'Field Service',
		Repair_Date__c = System.today(),
        SVMXC__Order_Status__c ='Processing Error',
        Reason_For_Denial__c = 'Test denial'
        );
         
        try{
        insert SampleWorkOrder1;
        }
               catch (Exception e) {
                system.debug('sample work order 1 insert error is '+e.getMessage());
                }     
        System.debug('The work order number is: ' +SampleWorkOrder1.Name);
        
        //assert that the processed date and processed by fields are set correctly on insert
        SVMXC__Service_Order__c wo = [Select Id, Processed_Date__c, Processed_By__c From SVMXC__Service_Order__c Where Id = :SampleWorkOrder1.Id];
        System.assertEquals(wo.Processed_Date__c, System.today());
        System.assertEquals(wo.Processed_By__c, UserInfo.getName());
        
                        
        SVMXC__Service_Order__c  SampleWorkOrder2 = [SELECT Id ,Product__c, SVMXC__Order_Status__c, Reason_For_Denial__c FROM SVMXC__Service_Order__c where Id= :SampleWorkOrder1.Id ];
        SampleWorkOrder2.Product__c = Part.Id;        
        SampleWorkOrder2.SVMXC__Service_Group__c =sg.Id;
        SampleWorkOrder2.SVMXC__Company__c  = ac.Id;
        SampleWorkOrder2.SVMXC__Order_Status__c = 'Warranty Denied';
        SampleWorkOrder2.Reason_For_Denial__c = 'Test denial';
        try{
        update SampleWorkOrder2;
        }
               catch (Exception e) {
                system.debug('svol insert error is '+e.getMessage());
                }
        //assert that the processed date and processed by fields are set correctly on update
        SVMXC__Service_Order__c wo2 = [Select Id, Processed_Date__c, Processed_By__c From SVMXC__Service_Order__c Where Id = :SampleWorkOrder2.Id];
        System.assertEquals(wo.Processed_Date__c, System.today());
        System.assertEquals(wo.Processed_By__c, UserInfo.getName()); 
        
        SampleWorkOrder2.Amount__c = 0;
        SampleWorkOrder2.SVMXC__Order_Status__c = 'Warranty Processed';
        
        try{
        	update SampleWorkOrder2;
        }
        catch (Exception e) {
                System.Assert(e.getMessage().contains ('A dollar amount is required'));
                }
        
                                
        SVMXC__Service_Order__c  SampleWorkOrder3 = new SVMXC__Service_Order__c (
        SVMXC__Case__c = cs2.Id ,
        SVMXC__Contact__c =ct.Id,
        Product__c = Part.Id,
        SVMXC__Company__c  = ac.Id,
        Product_Model__c = 'Automation',
        Installation_Date__c = System.today(),
        SVMXC__Order_Status__c = 'Open',
        SVMXC__Priority__c = 'Medium',
        SVMXC__Order_Type__c = 'Field Service',
        Street__c = '123 test street',
        City__c = 'test city',
        State__c = 'test state',
        CaseProductGroup__c = 'Filter',
        Case_Problem_Code__c = 'FP93: WS STOCKING',
        SVMXC__Problem_Description__c = 'test description',
        SVMXC__Service_Group__c =sg.Id,
        RecordTypeId = rt1.Id); 
        try{
        insert SampleWorkOrder3;
        }
               catch (Exception e) {
                system.debug('svol insert error is '+e.getMessage());
                }
        
        SVMXC__Service_Order__c  SampleWorkOrder4 =  [SELECT Id ,Product__c FROM SVMXC__Service_Order__c where Id= :SampleWorkOrder1.Id ];
        SampleWorkOrder2.Product__c = Part.Id;
        SampleWorkOrder2.SVMXC__Service_Group__c =sg.Id;
        SampleWorkOrder2.SVMXC__Company__c  = ac.Id;
        try{
        update SampleWorkOrder4;
        }
               catch (Exception e) {
                system.debug('svol insert error is '+e.getMessage());
                } 
        }                  
     }

 

  • July 23, 2013
  • Like
  • 0

What I am trying to do is update a custom date field.  I want to put the date of the last activity that does not contain "Act-On Email" into the field "Last_Activity_by_Account_Owner__c".

 

The trigger works great until I do a mass update to trigger the trigger on previous tasks, but then I run into System.LimitException: Too many SOQL queries: 101.   I believe it is because I have a query inside the for loop, but I am new to Triggers and I dont know how to fix it.

 

My code:

 

trigger LastActDate2 on Task (after insert, after update) {
    
    
    //To do - If the subject of a completed task does not contain "Act-On Email", put the date of the completed task in the
    //"Last_Activity_by_Account_Owner__c" field on the account object

//Create a set of related account ID's
Set <ID> acctIDs = new Set <ID> ();


//For every task, add it's related to account ID to the set
 for (Task t: Trigger.new){
    if (t.accountID != NULL){
      acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
      Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID,Account_Owner_Role__c, Last_Activity_by_Account_Owner__c from Account where ID in :acctIDs]);
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line contains "Act-On Email", the account record owner's role matches the task record owner's role, and the task has been marked as completed
//Check to see if the Last_Activity_by_Account_Owner__c field is current compared with the latest completed activity    
    If (((!t.subject.contains('Act-On Email'))&&acctMap.get(t.accountID).Account_Owner_Role__c == t.Task_Owner_Role__c && (t.Status == 'Completed')) &&
    (acctMap.get(t.accountID).Last_Activity_by_Account_Owner__c  < t.ActivityDate || acctMap.get(t.accountID).Last_Activity_by_Account_Owner__c  ==null )){
//Update the Last_Activity_by_Account_Owner__c field on the account object with the task's end date  
          acctrec.Last_Activity_by_Account_Owner__c  = t.ActivityDate;
    
      }
    update acctRec;
  }
  }
  }

Hi all,

 

We are working on a sites project and we need to show images on a pdf file. We could see the images on visualforce pages actually. But in sites, we can't see what we expect. Is there a specific way to handle this in sites?

 

Thanks.

  • July 15, 2013
  • Like
  • 0

Hello All,

 

  I am using informatica to import data from external database table to an object in SFDC. The process is running fine except when i change it into Bulk mode. I get the following exception in SFDC:

 

InvalidBatch : type is not needed for non polymorphic foreign key references

 

I see this exception in Bulk Data Load Jobs under setup menu. Any pointers as to the reason would be very helpful. 

 

Thank you in advance.

Regards,

KB