• dev_sfdc1
  • NEWBIE
  • 309 Points
  • Member since 2014

  • Chatter
    Feed
  • 9
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 74
    Replies
I've poured over a lot of the posts (there are pages of them) with CSS/VIsualforce problems on the forums, and either the issues don't apply to mine, of I've already tried the solution.

I'm trying to use a set of css and js files in a visualforce page to mimic the style and format of my website.  There are multiple references to both css and js files.  Those files are in a zip file in static resources.  My references are working because the images are displaying, but they styles aren't.

I believe I've set the page attributes correctly:

<apex:page showheader="false" sidebar="false" standardstylesheets="false">

And I believe I've correctly referenced the css file:

<apex:stylesheet value="{!URLFOR($Resource.customHelpAssets2, '/css/style.css')}"/>
and 
<apex:stylesheet value="{!URLFOR($Resource.customHelpAssets2, 'css/camera.css')}" id='camera-css' />

and the js files.

<apex:includeScript value="{!URLFOR($Resource.customHelpAssets2, 'scripts/jquery.min.js')}"  />

I've tried putting a slash in front of the folder in the reference: '/css/camera.css'  With or without doesn't seem to make a difference.  The zip file - customHelpAssets2 is public.

Anything else I could be missing?  Is there a limit to the number of stylesheets or external files I can include?

Thanks in advance!

Jeremy




 
I am working on opportunity products and came accross a youtube video where you were able to select multiple products and add them to one opportunity all from the same page. Currently, when we "select" a product for an opportunity we are directed to another page to fill out quantity, price, etc. is there a way to get that all on one page so we are not constantly going back and forth?
The layout in this video is the layout I am looking to replicate:https://www.youtube.com/watch?v=jQPTnfmHU2U
I've run into a problem with my Test code for a Controller extension.  The error message I get is: Constructor not defined: [Test_Line_Edit_Extension].&lt;Constructor&gt;(ApexPages.StandardController).  I need to get this fixed so I can deploy it to production to enable me to get rid of code that somehow made it into Production without accompanying test code.  Here is my test code:
@istest
public class Test_Line_Edit_Extension 
{
	public static testmethod void Test_Line_Edit_Extension()
	{
        Order_Line_Item__c initLI = new Order_Line_Item__c();
        ApexPages.StandardController sc = new ApexPages.standardController(initLI);
        Test_Line_Edit_Extension ext1 = new Test_Line_Edit_Extension(sc);
        ext1.getRecord(initLI);
        
       	Product2 myProduct = [select id, ProductCode, Family, Description
    	from Product2 where productCode = 'K PSIP MSL' Limit 1];
		Order__c myOrder = new Order__c();
		List<Order__c>OrdersList = new List<Order__c>();
		List<Order_Line_Item__c> LIList = new List<Order_Line_Item__c>();
		Account testAccount = new Account(Name = 'KBB Test Account');
		insert testAccount;
        if(testAccount.id != null)
        {
			myOrder = new Order__c(Customer_Account__c = testAccount.id);
		
			for(integer x = 1; x< 10;x++)
			{
			Order_Line_Item__c myLineItem = new Order_Line_Item__c(Name = myProduct.productCode + x, Price_per_unit__c = x,
            Quantity__c = 3, Year_of_Contract__c = 2,Type_of_Sale__c = 'Renewal',Order_Number__c = myOrder.id);
			system.assertEquals(myProduct.name, 'K PSIP MSL');
			system.assertEquals(myProduct.productCode, myLineItem.Product__c);
            }
        }
    }
	

}

Here is the code I'm trying to test:
public with sharing class LineEditExtension {

    private final Order_Line_Item__c m_ext {get;set;}
    public Order_Line_Item__c currentLine {get;set;}
    public ApexPages.StandardController m_con {get;set;}
    public ApexPages.StandardController m_Gstd {get;set;}
    public string m_currentLineId {get;set;}    
   
    public LineEditExtension(ApexPages.StandardController stdController){ 
        m_ext = (Order_Line_Item__c)stdController.getRecord();
    }
    
    public PageReference SaveAndNew(){
        ApexPages.StandardController m_Gstd = new ApexPages.StandardController(m_ext);
        PageReference OrderPage = m_Gstd.save(); 
        m_currentLineId=m_Gstd.getId(); 
        PageReference returnPage = new PageReference('/a07/e');
        return returnPage;
    }                                          
}

And here's the page:
<apex:page standardController="Order_Line_Item__c" extensions="LineEditExtension">
    <apex:sectionHeader title="{!$ObjectType.Order_Line_Item__c.label} Edit" subtitle="{!Order_Line_Item__c.name}"/>
    <apex:form >
    <apex:pageBlock title="{!$ObjectType.Order_Line_Item__c.label} Edit" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!saveAndNew}" value="Save & New"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection showHeader="true" title="Information" columns="2">
            <apex:inputField required="true" value="{!Order_Line_Item__c.Product__c}"/>
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem />
            <apex:inputField required="true" value="{!Order_Line_Item__c.Order_Number__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Length_of_Subscription__c}"/>
            <apex:pageBlockSectionItem />
            <apex:inputField value="{!Order_Line_Item__c.Year_of_Contract__c}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection showHeader="true" title="Details" columns="2">
            <apex:inputField value="{!Order_Line_Item__c.Quantity__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Type_of_Sale__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Price_per_Unit__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.New_Money__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Renewal_Increase_money__c}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection showHeader="true" title="System Information" columns="2">
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem />
            <apex:inputField required="true" value="{!Order_Line_Item__c.Name}"/>
            <apex:pageBlockSectionItem />
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Any insight will save my sanity.
Thanks,
KathyBB
  • September 25, 2014
  • Like
  • 0
Hi All,

I'm new to apex coding and I'm banging my head on the wall to write a test class and be able deploy my apex class but with no result yet. The aim is to display a list of accounts which respect certain criteria- being an active member and being a small organisation. I've used my class in a page and it seems to work fine in the sandbox.
I've looked at examples of test classes but none seems to work. Any good samaritan out there who can give me a hand?

This is my class:

public with sharing class Small_members {
List<Account> accounts;
public List<Account> getAccounts(){
accounts = [SELECT name, Phone, County__c, Website, Category_ID__c from account WHERE (OrgMembership_Status__c = 'Active' and Category_ID__c='Small Organisation') ORDER BY Name];
return accounts;
}
}

and this is my test class so far - not working :-(

@isTest
public class Testmallmembers { static testMethod void t1()
{ account a = new Account( name='accountmember1', Phone='045-555555', County__c='Countysoandso', Website='http://www.website.ie') ;
insert a;
Testmallmembers Small_members = new Small_members();
List<Contact> l = Small_members.getAccounts();
system.assert( l.size() > 0 ); }
public List<Account> 'accountmember1';
                           }

Any tips on how to proceed would be appreciated. Thank you.
Hi, 

I am wanting to create a pop up box from my visualforce page, this pop up will give a text box that the user can enter infomation and then save it toa table I have created in the the visualforce page.

any advice on this would be great!
Good Morning:

Please see the attached VF page and image. I am having trouble figuring out how to space out my field labels and fields so they are all symemtrical and easy to look at. Any help would be appreciated.

<apex:page standardController="Fioptics_Notify_Me__c" extensions="fiopticsNotifyMeExtension" sidebar="FALSE" showHeader="FALSE" standardStylesheets="False">
<style>
    .activeTab {background-color:white; color:black; background-image:none; font-weight: bold}
    .inactiveTab {background-color:lightgrey; color:black; background-image:none; font-weight:bold}
    .pageBlockStyle {text-align:left; width:30%}
    .bPageBlock .pbBody {background:white;}
</style>   
        <apex:form styleClass="pageBlockStyle">      
            <apex:tabPanel switchType="client" selectedTab="fioptics2" id="theTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
                <apex:tab label="Fioptics" name="fioptics1" id="tabOne" labelWidth="50px">
                    <apex:pageBlock >
                        <apex:pageBlockSection title="Customer Information" columns="1">
                            <apex:inputField label="Name" value="{!Fioptics_Notify_Me__c.Name}" required="TRUE" style="width: 200px; height: 20px nowrap;"/>
                            <apex:inputField label="Contact Number" value="{!Fioptics_Notify_Me__c.Contact_Number__c}" required="TRUE" style="width: 200px; height: 20px nowrap"/>
                            <apex:inputField label="Address" value="{!Fioptics_Notify_Me__c.Address__c}" required="TRUE" style="width: 200px; height: 20px nowrap"/>  
                            <apex:inputField label="Customer Email" value="{!Fioptics_Notify_Me__c.Customer_E_mail__c}" style="width: 200px; height: 20px nowrap"/>
                        </apex:PageBlockSection>
                        <apex:pageBlockSection title="Consultant Information" columns="1">  
                            <apex:inputField label="Store" value="{!Fioptics_Notify_Me__c.Store__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/> 
                            <apex:inputField label="Consultant Email" value="{!Fioptics_Notify_Me__c.Consultant_Email__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/>      
                            <apex:inputField label="Consultant" value="{!Fioptics_Notify_Me__c.Consultant_Name__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/>     
                        </apex:PageBlockSection>
                        <apex:pageBlockSection title="Products Information" columns="1">      
                            <apex:inputField label="Video" value="{!Fioptics_Notify_Me__c.Video__c}" style="width: 300px; height: 20px nowrap"/>  
                            <apex:inputField label="Internet" value="{!Fioptics_Notify_Me__c.Internet__c}" style="width: 300px; height: 20px nowrap"/>      
                            <apex:inputField label="Phone" value="{!Fioptics_Notify_Me__c.Phone__c}" style="width: 300px; height: 20px nowrap"/>    
                            <apex:inputField label="Notes" value="{!Fioptics_Notify_Me__c.Notes__c}" style="width: 300px; height: 50px nowrap"/>   
                            <apex:commandButton value="Submit" action="{!saveLead}" style="float:left"/>   
                        </apex:pageBlockSection>
                    </apex:pageBlock>
                </apex:tab>
                <apex:tab label="CBW" name="fioptics2" id="tabTwo" labelWidth="50px">
                    <apex:pageBlock mode="mainDetail">
                        <apex:pageBlockSection title="Customer Information" columns="1">
                            <apex:inputField label="Name" value="{!Fioptics_Notify_Me__c.Name}" required="TRUE" style="width: 300px; height: 20px nowrap"/>
                            <apex:inputField label="Contact Number" value="{!Fioptics_Notify_Me__c.Contact_Number__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/>
                            <apex:inputField label="Address" value="{!Fioptics_Notify_Me__c.Address_Free__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/>  
                            <apex:inputField label="Customer Email" value="{!Fioptics_Notify_Me__c.Customer_E_mail__c}" style="width: 300px; height: 20px nowrap" />                              
                        </apex:pageBlockSection>
                        <apex:pageBlockSection title="Consultant Information" columns="1">  
                            <apex:inputField label="Store" value="{!Fioptics_Notify_Me__c.Store__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/> 
                            <apex:inputField label="Consultant" value="{!Fioptics_Notify_Me__c.Consultant_Name__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/>  
                        </apex:PageBlockSection>
                        <apex:pageBlockSection title="CBW Information" columns="1">      
                            <apex:inputField label="#of Lines" value="{!Fioptics_Notify_Me__c.of_Lines__c}" required="TRUE" style="width: 300px; height: 20px nowrap"/>  
                            <apex:inputField label="Current Plan" value="{!Fioptics_Notify_Me__c.Current_Plan__c}" style="width: 300px; height: 20px nowrap"/>         
                            <apex:inputField label="Notes" value="{!Fioptics_Notify_Me__c.Notes__c}" style="width: 300px; height: 50px nowrap"/>  
                            <apex:commandButton value="Submit" action="{!saveLead}" style="float:left"/>   
                        </apex:pageBlockSection>
                    </apex:pageBlock>                                                      
                </apex:tab>                         
            </apex:tabPanel>                                  
        </apex:form>          
</apex:page>




VF Page Screenshot
Thanks,

Matt
Can we override standard Save & New , Save & Close buttons in Case Edit Page ???
Hi, I am very very new to APEX, but not new to Salesforce. I need to auto populate a picklist field on related obect from the parent object, due to the other picklist field is a controlling field for another multi-select picklist field. Here are the details: I would like to take the "BillingState" field from Accounts and use the value there to autopopluate a picklist field, "State__c" on Cases then pass the information to the field "Customer_State__c" on my custom object, Internal_Buy_Rate__c. I did find the following answer, https://developer.salesforce.com/forums/ForumsMain?id=906F000000093U9IAI, I am stuck on how to modify this to suit my purposes for the text field from accounts and than pass that information down to my related objects. Any help would be greatly appreciated. 

Thank-you.

Shane
Hi All,
I want to rename the confirm box buttons(OK,CANCEL) with 'Yes' and 'NO'.
Is there any way to do it using Javascript.


Thanks,
Raj.
  • April 07, 2014
  • Like
  • 0
Hi 
I'm getting Error in Test Class like below :
System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Auto_generated: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Test Class:

@isTest 
private class Emailtocase_TestClass
{
     static TestMethod void Emailtocase_TestClass()
    {
        
        Test.StartTest();  
        
        Case c= new Case();
        c.Subject = 'Testing';
        //insert c;
       
        
       Contact con = new Contact();
       con.LastName = 'Testing Contact';
       con.Email = 'test1@gmail.com'; 
       insert con;  
       Contact c1 = [Select id,LastName,Email from Contact where Email = 'test1@gmail.com'];
        
        Case ca = new Case();
        ca.Id = c.Id;
        ca.Subject='Welcome';
        ca.Status = 'email';
        ca.Origin='New';
        ca.ContactId = c1.Id;
        ca.SuppliedEmail= 'test1@gmail.com';
        ca.Task_Taken__c=false;
        ca.OwnerId = '00G90000002Gb76';
        upsert ca;
        
        Account a = new Account();
        a.Domain_Name__c = 'gmail.com';        
        a.Name='Testing Account';
        insert a;
        Account a1 = [Select id,Domain_Name__c,Name,Phone from Account where Domain_Name__c = 'gmail.com'];
        Case cas1= new Case();
        cas1.Subject = 'Testing';
        cas1.SuppliedEmail= 'test@gmail.com';
        
        List<contact> lstcon =new List<contact>();
        contact con1=new contact(lastname='sas',Email = cas1.SuppliedEmail,AccountId=a1.Id);
        lstcon.add(con1);
        insert lstcon;
        
       
        
       Case ca1 = new Case();
        ca1.Id = cas1.Id;        
        ca1.Subject='Welcome';
        ca1.Status = 'email';
        ca1.Origin='New';       
        ca1.AccountId=a1.Id;
        ca1.Task_Taken__c=false;
        ca1.OwnerId = '00G90000002Gb76';       
        ca.ContactId = lstcon[0].Id;
        Upsert ca1;// Here I'm getting error line is -Class.Emailtocase_TestClass.Emailtocase_TestClass: line 57, column 1
      
        Test.StopTest();
        
        
        
    }
}
The above covers 54% so how to solve this error.

Thanks
Hi,
I tried to insert queue CaseOwner whenever Case is created.But it was failing to update. Even I tried to hardcode but its not working to me.
Please help me to assign.
trigger testChangeOwnerTrigger on Case (before insert) 
{
 //List<QueueSobject> queueuser = [SELECT Id,queue.Name, QueueId FROM QueueSobject WHERE SobjectType = 'Case' and queue.Name = 'Unassigned' limit 1];
     for(Case newCase : Trigger.New) 
     { 
         newCase.OwnerId ='00G90000001hkVN'; 
     }
     
}
Hi
I'm deleting cases, before inserting cases through mail based on domain condition.Please help me.
trigger Auto_generated on Case (after insert) {
    List<Case> emDelList = new List<Case> ();     
    for (Case em : Trigger.New) {   // bulkified      
      List<String> mailsplit;
      String Result;
      mailsplit  = em.SuppliedEmail.Split('@');
      Result = mailsplit [1];
       if(em.SuppliedEmail != null)
        {
        if(Result.contains('gmail.com'))
          emDelList.add(em);
       } 
    }
    
delete emDelList;
}

Error: DML statement cannot operate on trigger.new or trigger.old
Hi,
I have to customize Email to Case . Please help me.
My scenario is,
If my domain name is filled with values in accounts and based on that email field is filled in Contacts, then I need to create Case through Email to Case.But here my problem is Email is not firing through this trigger.
Trigger UpatestatusonCase on EmailMessage (before insert) 
{
        List<Contact> lstcon = new List<Contact>();
        List<Account> lstacc = [ Select id,Name from Account where Domain_Name__c ='www.techlab.com'];
        if(lstacc.size() > 0)
        {      
        lstcon= [Select id,Email,AccountId from Contact where AccountId =: lstacc[0].id and Email = 'tech@techlab.com'];
        }
        if(lstcon.size() > 0)
        {
        for(Contact con : lstcon)
        {
        String stremail = lstcon[0].Email;
        List<EmailMessage> em= new List<EmailMessage>();   
        em=[select id,parentid,FromAddress from EmailMessage where id =: em[0].id and FromAddress =: stremail];
        system.debug('1'+em[0].FromAddress);
        //String emid = em[0].Parentid;
        if(em.size() > 0)
        {
        system.debug('2passed');
        List<Case> cs= new List<Case>();
        for(EmailMessage e : em)
        {
            if(e.FromAddress != '')
            {
                 cs.add(new Case(Subject = e.Subject,Origin = 'Email',Status = 'New',Description = e.TextBody,SuppliedEmail = e.FromAddress));
            }
        }
        insert cs;
        
        
       }
       }
       }
     
  
}

Thank You
I have one scenario for Email to Case Customisation(for this I have some conditions to create new cases):

User sends request via email link on website,
Condition:
1.If that domain listed on Account page,then new case is created.
2.If it is not on Account then it will check availability in contact,then new case is created.
I need to go for trigger or else someother validation.Is this possible to customise email to case in salesforce.
Please give me some idea to start.

Thank You
Hi,
I'm new to trigger concepts.My requirement is if any CampaignMember is created for particular two Campaign records,task is created to that contacts.For me, task is not created in this trigger.Please point me out where I did mistake.

Trigger:

trigger add_task on CampaignMember (before Insert) 
{
    List<Campaign> c = [select Id,Name from Campaign where Id = :Trigger.new[0].CampaignId]; 
    List<Campaign> lstc = new List<Campaign>();
    
    for(Campaign cpn : c)
    {
    if(cpn.Name == 'First Mail' || cpn.Name == 'Second Mail' )
       
        lstc.add(cpn);
    }
  
    List<CampaignMember> lstcm = [Select id,CampaignId,ContactId,Status from CampaignMember where CampaignId =: lstc];
    List<Id> Contact_Lead_Ids= new List<Id>();
    for(CampaignMember cm : lstcm)  
    
        Contact_Lead_Ids.add(cm.ContactId);
        System.Debug('ContactId=='+Contact_Lead_Ids);     

    List<Contact> contacts=[Select Id from Contact where Id in :Contact_Lead_Ids];  
    List<Contact> cidcon = new List<Contact>();
    for(Contact ct : contacts)       
       cidcon.add(ct);
       
    List<CampaignMember> lstmember = [Select id,CampaignId,ContactId,Status from CampaignMember where ContactId =: cidcon];
    
    for(CampaignMember cm2 : lstmember) 
    {
        if(cm2.ContactId!=NULL & cm2.Status == 'Responded')
        {
           
            Task myTask=new Task(Whoid=cm2.ContactId,Subject='Testing Task Created');
            Insert myTask;
            System.Debug('Task inserted to=='+myTask);
        }
    
    }
    
   

}

Thank You
Hi
We have installed Service Max managed package.
We are getting trigger error on WorkOrder object while creating a record
on WorkOrder Object.We need a help or workaround to solve this issue.


Trigger Error below:

SVMXC.WORD_Trigger1:execution of BeforeInsert caused by: System.NullPointerException:
Attempt to de-reference a null object:(SVMXC)
global class Account
{
    webService static void  getacc(Account obj,Integer id)
    {        
        obj.Number_Id__c = id;     
        insert obj;       
           
    }
}

@isTest
private class accwebservice
{
    static void testclass()
    {    
           Account.getacc(123);      
     
    }
}

Help me to write test class..
Hi,
I'm having scenario in task object,
If the checkbox "Send Notification Email " checkbox is checked and  "Status" is updated, then send an email to user. If the checkbox is not checked, the user will not receive an email.How to achieve this ?

Right now I'm thinking that through workflow is not possible.
So my second option is trigger.
But here my code is working only if status is updated then user will get mail. In trigger, don't have idea to set condition for checkbox is checked or not..

I'm new to trigger concept pls help to achieve this....


trigger Task_Email on Task (before update) {
 
    Set<Id> ownerIds = new Set<Id>();
 
    for(Task tsk: Trigger.New)
        ownerIds.add(tsk.ownerId);
 
 
    Map<Id, User> userMap = new Map<Id,User>([select Name, Email from User where Id in :ownerIds]);
    for(Task tsk : Trigger.New)
    {
        User theUser = userMap.get(tsk.ownerId);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {theUser.Email};
        mail.setToAddresses(toAddresses);    // Set the TO addresses
        mail.setSubject('A task owned by you has been updated');    // Set the subject
        // Next, create a string template. Specify {0}, {1} etc. in place of actual values.
        // You can replace these values with a call to String.Format.
        String template = 'Hello {0}, \nYour task has been modified. Here are the details - \n\n';
        template+= 'Status- {1}\n';
   
         List<String> args = new List<String>();
        args.add(theUser.Name);
       args.add(tsk.Status);
            
     
        String formattedHtml = String.format(template, args);
     
        mail.setPlainTextBody(formattedHtml);
        Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
    }
}


Please share your ideas.

Thank you
Apex class:

public PageReference Save()
{
    service.Asset_Name__c =assetname;
    insert service;

   Task T = new Task();
        T.WhatId=assetname;
        T.WhoId=service.Employee__c;
        T.OwnerId= UserInfo.getUserId();

        insert T;

    PageReference ref= new PageReference('/'+assetname);
    ref.setredirect(true);
    return ref;
}


Test Class:

static TestMethod void ServiceRecordAssetTestClass()
    {
        PageReference ref = Page.ServiceRecord;
        Test.setcurrentPage(ref);

        Account acc = new Account(Name='Test');
        insert acc;

        Contact con = new Contact(LastName='Test2');
        insert con;

        Physical_Asset__c phy = new  Physical_Asset__c(Name='PhysicalAssetName',Vendor_Account__c=acc.id);
        insert phy;

        Service_Record__c testservice = new Service_Record__c(Name='Test Service',Employee__c=con.id,Asset_Name__c=phy.id);
        insert testservice;

        Task t = new Task(Subject='Task Name');
        insert t;

        ApexPages.CurrentPage().getParameters().put('retURL','/'+phy.Id);
        ApexPages.StandardController sc = new ApexPages.StandardController(testservice);

        ServiceRecordAsset  sr = new ServiceRecordAsset(sc);

        String nextPage=sr.Save().getUrl();-----------> Getting Error
        system.assertEquals('/'+phy.id,nextpage);

        //sr.save();
    }
}


Error is:

System.DmlException: Insert failed. First exception on row 0 with id a0ge0000000T3UqAAK; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

otherwise it covers 30%.

Please help me to resolve this error.
Hi..

I'm having error like this.. so I'm not getting any code coverage..
Class.AssetParts.<init>: line 10, column 1
Class.AssetPartsTestClass.AssetPartsTestClass: line 26, column 1

Apex Class:

public with sharing class AssetParts {
  public Asset_Part__c astpart;
  public Physical_Asset__c asset{get;set;}
  public string assetname;
    public AssetParts(ApexPages.StandardController con)
    {
        astpart=(Asset_Part__c)con.getRecord();
        String astname = ApexPages.currentPage().getParameters().get('retURL');
        string[] strsplit = astname.split('/');
        assetname = strsplit[1];---------------> here class error
         asset= new Physical_Asset__c();
       
           
    }
    public String errmsg{get;set;}
    public PageReference Save()
    {
            astpart.Asset_Name__c =assetname;
            insert astpart;
                           
            PageReference ref= new PageReference('/'+assetname);
            ref.setredirect(true);
            return ref;
        }
    }  
   My test class is:

@isTest
public class AssetPartsTestClass
{
     static TestMethod void AssetPartsTestClass()
    {
      PageReference ref = Page.AssetParts;
      Test.setcurrentPage(ref);
     
     
      Account testAccount = new Account(Name='Test Company Name');
      insert testAccount;
    
      Physical_Asset__c phy = new Physical_Asset__c(Name='Physical Asset Name',Vendor_Account__c=testAccount.id);
      insert phy;
     
      Asset_Part__c testassetpart = new Asset_Part__c(Name='Test Assetpart Name',Vendor_Account__c=testAccount.id,Asset_Name__c =phy.id);
      insert testassetpart;
     
        
     
      ApexPages.currentPage().getParameters().put('assetname',phy.id);
      ApexPages.StandardController sc = new ApexPages.StandardController(testassetpart);     
    
      AssetParts  ap = new AssetParts(sc);---------->test class error
      ap.save();
          
    }
}


Please help me from this..
Hi
We have installed Service Max managed package.
We are getting trigger error on WorkOrder object while creating a record
on WorkOrder Object.We need a help or workaround to solve this issue.


Trigger Error below:

SVMXC.WORD_Trigger1:execution of BeforeInsert caused by: System.NullPointerException:
Attempt to de-reference a null object:(SVMXC)
trigger ParentChildcase on Case (before update) {
List<Id> parentCaseIds = new List<Id>();

Map<Id,Case> caseMap =new Map<Id,Case> ([select id  from Case where Id in:parentCaseIds]);
/*List<case> OpenChildCases = [select Id from case Id:Trigger.NewMap.Keyset() and status != 'Closed']
Set<String> ChildCaseSet = New Set<string>();
    for(case temp:OpenChildCases){
        ChildCaseSet.add(temp.Parent.Id);
    }
    for(case caseinst:Trigger.New){
      if(ChildCaseSet.contains(caseinst.Id) && caseinst.Status = 'Closed'){
        caseinst.addError('Unclosed Child Records are Present');
     }   
   }*/
}
User-added image
In the above image i would like to add 3rd, 4th and so on upto 10 option on click of add option and implement reove link to remove perticular option(textarea) and if question type is descriptive i would like to hide all options
I've poured over a lot of the posts (there are pages of them) with CSS/VIsualforce problems on the forums, and either the issues don't apply to mine, of I've already tried the solution.

I'm trying to use a set of css and js files in a visualforce page to mimic the style and format of my website.  There are multiple references to both css and js files.  Those files are in a zip file in static resources.  My references are working because the images are displaying, but they styles aren't.

I believe I've set the page attributes correctly:

<apex:page showheader="false" sidebar="false" standardstylesheets="false">

And I believe I've correctly referenced the css file:

<apex:stylesheet value="{!URLFOR($Resource.customHelpAssets2, '/css/style.css')}"/>
and 
<apex:stylesheet value="{!URLFOR($Resource.customHelpAssets2, 'css/camera.css')}" id='camera-css' />

and the js files.

<apex:includeScript value="{!URLFOR($Resource.customHelpAssets2, 'scripts/jquery.min.js')}"  />

I've tried putting a slash in front of the folder in the reference: '/css/camera.css'  With or without doesn't seem to make a difference.  The zip file - customHelpAssets2 is public.

Anything else I could be missing?  Is there a limit to the number of stylesheets or external files I can include?

Thanks in advance!

Jeremy




 
Hi 
I'm getting Error in Test Class like below :
System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Auto_generated: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Test Class:

@isTest 
private class Emailtocase_TestClass
{
     static TestMethod void Emailtocase_TestClass()
    {
        
        Test.StartTest();  
        
        Case c= new Case();
        c.Subject = 'Testing';
        //insert c;
       
        
       Contact con = new Contact();
       con.LastName = 'Testing Contact';
       con.Email = 'test1@gmail.com'; 
       insert con;  
       Contact c1 = [Select id,LastName,Email from Contact where Email = 'test1@gmail.com'];
        
        Case ca = new Case();
        ca.Id = c.Id;
        ca.Subject='Welcome';
        ca.Status = 'email';
        ca.Origin='New';
        ca.ContactId = c1.Id;
        ca.SuppliedEmail= 'test1@gmail.com';
        ca.Task_Taken__c=false;
        ca.OwnerId = '00G90000002Gb76';
        upsert ca;
        
        Account a = new Account();
        a.Domain_Name__c = 'gmail.com';        
        a.Name='Testing Account';
        insert a;
        Account a1 = [Select id,Domain_Name__c,Name,Phone from Account where Domain_Name__c = 'gmail.com'];
        Case cas1= new Case();
        cas1.Subject = 'Testing';
        cas1.SuppliedEmail= 'test@gmail.com';
        
        List<contact> lstcon =new List<contact>();
        contact con1=new contact(lastname='sas',Email = cas1.SuppliedEmail,AccountId=a1.Id);
        lstcon.add(con1);
        insert lstcon;
        
       
        
       Case ca1 = new Case();
        ca1.Id = cas1.Id;        
        ca1.Subject='Welcome';
        ca1.Status = 'email';
        ca1.Origin='New';       
        ca1.AccountId=a1.Id;
        ca1.Task_Taken__c=false;
        ca1.OwnerId = '00G90000002Gb76';       
        ca.ContactId = lstcon[0].Id;
        Upsert ca1;// Here I'm getting error line is -Class.Emailtocase_TestClass.Emailtocase_TestClass: line 57, column 1
      
        Test.StopTest();
        
        
        
    }
}
The above covers 54% so how to solve this error.

Thanks
Hi,
I tried to insert queue CaseOwner whenever Case is created.But it was failing to update. Even I tried to hardcode but its not working to me.
Please help me to assign.
trigger testChangeOwnerTrigger on Case (before insert) 
{
 //List<QueueSobject> queueuser = [SELECT Id,queue.Name, QueueId FROM QueueSobject WHERE SobjectType = 'Case' and queue.Name = 'Unassigned' limit 1];
     for(Case newCase : Trigger.New) 
     { 
         newCase.OwnerId ='00G90000001hkVN'; 
     }
     
}
Hi,
I have to customize Email to Case . Please help me.
My scenario is,
If my domain name is filled with values in accounts and based on that email field is filled in Contacts, then I need to create Case through Email to Case.But here my problem is Email is not firing through this trigger.
Trigger UpatestatusonCase on EmailMessage (before insert) 
{
        List<Contact> lstcon = new List<Contact>();
        List<Account> lstacc = [ Select id,Name from Account where Domain_Name__c ='www.techlab.com'];
        if(lstacc.size() > 0)
        {      
        lstcon= [Select id,Email,AccountId from Contact where AccountId =: lstacc[0].id and Email = 'tech@techlab.com'];
        }
        if(lstcon.size() > 0)
        {
        for(Contact con : lstcon)
        {
        String stremail = lstcon[0].Email;
        List<EmailMessage> em= new List<EmailMessage>();   
        em=[select id,parentid,FromAddress from EmailMessage where id =: em[0].id and FromAddress =: stremail];
        system.debug('1'+em[0].FromAddress);
        //String emid = em[0].Parentid;
        if(em.size() > 0)
        {
        system.debug('2passed');
        List<Case> cs= new List<Case>();
        for(EmailMessage e : em)
        {
            if(e.FromAddress != '')
            {
                 cs.add(new Case(Subject = e.Subject,Origin = 'Email',Status = 'New',Description = e.TextBody,SuppliedEmail = e.FromAddress));
            }
        }
        insert cs;
        
        
       }
       }
       }
     
  
}

Thank You
I have one scenario for Email to Case Customisation(for this I have some conditions to create new cases):

User sends request via email link on website,
Condition:
1.If that domain listed on Account page,then new case is created.
2.If it is not on Account then it will check availability in contact,then new case is created.
I need to go for trigger or else someother validation.Is this possible to customise email to case in salesforce.
Please give me some idea to start.

Thank You
Hi,
I'm new to trigger concepts.My requirement is if any CampaignMember is created for particular two Campaign records,task is created to that contacts.For me, task is not created in this trigger.Please point me out where I did mistake.

Trigger:

trigger add_task on CampaignMember (before Insert) 
{
    List<Campaign> c = [select Id,Name from Campaign where Id = :Trigger.new[0].CampaignId]; 
    List<Campaign> lstc = new List<Campaign>();
    
    for(Campaign cpn : c)
    {
    if(cpn.Name == 'First Mail' || cpn.Name == 'Second Mail' )
       
        lstc.add(cpn);
    }
  
    List<CampaignMember> lstcm = [Select id,CampaignId,ContactId,Status from CampaignMember where CampaignId =: lstc];
    List<Id> Contact_Lead_Ids= new List<Id>();
    for(CampaignMember cm : lstcm)  
    
        Contact_Lead_Ids.add(cm.ContactId);
        System.Debug('ContactId=='+Contact_Lead_Ids);     

    List<Contact> contacts=[Select Id from Contact where Id in :Contact_Lead_Ids];  
    List<Contact> cidcon = new List<Contact>();
    for(Contact ct : contacts)       
       cidcon.add(ct);
       
    List<CampaignMember> lstmember = [Select id,CampaignId,ContactId,Status from CampaignMember where ContactId =: cidcon];
    
    for(CampaignMember cm2 : lstmember) 
    {
        if(cm2.ContactId!=NULL & cm2.Status == 'Responded')
        {
           
            Task myTask=new Task(Whoid=cm2.ContactId,Subject='Testing Task Created');
            Insert myTask;
            System.Debug('Task inserted to=='+myTask);
        }
    
    }
    
   

}

Thank You

Hi,

There are 2 objects named A and B. These two object are connected through a Junction Object C.

A is the master of the Master Detail relation ship between A and C.

B and C are connected using a lookup relationship.
If i need to delete a record of object B based on certain condition of object A.

Then on which object do i need to write the trigger.

If there are examples for this sort of an application. Please suggest.

Any insight is appreciated.

Thank you.

  • October 28, 2014
  • Like
  • 0
I look for a way to change the color of a font with a formula depending on the survey responses of Excellent, Good, Fair.
my visualforce code is below. Any help would be aprreciated.



<apex:page standardController="Survey__c" showHeader="false">
  <apex:pageBlock title="Survey Questions"  >
 
 
 
<apex:panelGrid columns="1" >

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >1. Rate your overall experience with Cybex:</apex:outputLabel>

<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px;"  value="{!Survey__c.Q1__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:0px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >2. Rate your overall experience with your Cybex Territory Manager/Sales Representative:</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q2__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:0px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >3. Rate your overall experience with the Cybex order process</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q3__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:0px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >4. Did Cybex handle the delivery and/or installation of your equipment?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q4__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:0px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >5. Did your Cybex equipment arrive on schedule?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q5__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >6. If you requested to be contacted prior to delivery, were you?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q6__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >7. Did the installers test the equipment?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q7__c}"></apex:outputText>

<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888">8. Was your equipment intact and undamaged?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q8__c}"></apex:outputText>


<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px#888888" >9. Was the installation team courteous?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q9__c}"></apex:outputText>


<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >10. Was your order complete?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q10__c}"></apex:outputText>


<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >11. Was the equipment functioning properly?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q11__c}"></apex:outputText>


<apex:outputLabel style="line-height:25px;font-weight:bold;padding:3px;border-bottom-style: solid; border-bottom-width: 1px;border-color:grey;box-shadow: 0px 0px 0px #888888" >12. Did Cybex follow up with a phone call?</apex:outputLabel>
<apex:outputText style="line-height:25px;font-size:12px;padding-left:0px"  value="{!Survey__c.Q12__c}"></apex:outputText>



</apex:panelGrid>
</apex:pageBlock>
</apex:page>

 
  • October 22, 2014
  • Like
  • 0
I am working on opportunity products and came accross a youtube video where you were able to select multiple products and add them to one opportunity all from the same page. Currently, when we "select" a product for an opportunity we are directed to another page to fill out quantity, price, etc. is there a way to get that all on one page so we are not constantly going back and forth?
The layout in this video is the layout I am looking to replicate:https://www.youtube.com/watch?v=jQPTnfmHU2U
This must be pretty staright forward, but I am not sure why it's not working in sandbox.
I  want to change the company default language, but I am not seeing  any option to do that when I edit Company Profile. This is sandbox environemt. I tried the same thing in my developer edition and it was startight forward, but why it's language dropdown is not coming in sandbox ?  Even my profile is sys admin.

User-added image

Regards,
BSS
Hi Guys,

How to create a popup alert to custom object?
NOTE: I have using the popup alert using "Riptide Popup Alerts" pakage to standard object, Kindly give a with example
Hello.

I would like to include a VF page of an Account on a non-Salesforce website. Even though "Enable clickjack protection for non-setup customer Visualforce pages" isn't enabled it gives me the following error message:

Refused to display 'https://iwoca--c.eu1.visual.force.com/AccountID/m?isdtp=vw' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

<iframe height="600" width="500"  src="https://iwoca--c.eu1.visual.force.com/apex/VF_ECN_Account?id=AccountID">
  <p>Your browser does not support iframes.</p>
</iframe>

Any idea what to do?
I've run into a problem with my Test code for a Controller extension.  The error message I get is: Constructor not defined: [Test_Line_Edit_Extension].&lt;Constructor&gt;(ApexPages.StandardController).  I need to get this fixed so I can deploy it to production to enable me to get rid of code that somehow made it into Production without accompanying test code.  Here is my test code:
@istest
public class Test_Line_Edit_Extension 
{
	public static testmethod void Test_Line_Edit_Extension()
	{
        Order_Line_Item__c initLI = new Order_Line_Item__c();
        ApexPages.StandardController sc = new ApexPages.standardController(initLI);
        Test_Line_Edit_Extension ext1 = new Test_Line_Edit_Extension(sc);
        ext1.getRecord(initLI);
        
       	Product2 myProduct = [select id, ProductCode, Family, Description
    	from Product2 where productCode = 'K PSIP MSL' Limit 1];
		Order__c myOrder = new Order__c();
		List<Order__c>OrdersList = new List<Order__c>();
		List<Order_Line_Item__c> LIList = new List<Order_Line_Item__c>();
		Account testAccount = new Account(Name = 'KBB Test Account');
		insert testAccount;
        if(testAccount.id != null)
        {
			myOrder = new Order__c(Customer_Account__c = testAccount.id);
		
			for(integer x = 1; x< 10;x++)
			{
			Order_Line_Item__c myLineItem = new Order_Line_Item__c(Name = myProduct.productCode + x, Price_per_unit__c = x,
            Quantity__c = 3, Year_of_Contract__c = 2,Type_of_Sale__c = 'Renewal',Order_Number__c = myOrder.id);
			system.assertEquals(myProduct.name, 'K PSIP MSL');
			system.assertEquals(myProduct.productCode, myLineItem.Product__c);
            }
        }
    }
	

}

Here is the code I'm trying to test:
public with sharing class LineEditExtension {

    private final Order_Line_Item__c m_ext {get;set;}
    public Order_Line_Item__c currentLine {get;set;}
    public ApexPages.StandardController m_con {get;set;}
    public ApexPages.StandardController m_Gstd {get;set;}
    public string m_currentLineId {get;set;}    
   
    public LineEditExtension(ApexPages.StandardController stdController){ 
        m_ext = (Order_Line_Item__c)stdController.getRecord();
    }
    
    public PageReference SaveAndNew(){
        ApexPages.StandardController m_Gstd = new ApexPages.StandardController(m_ext);
        PageReference OrderPage = m_Gstd.save(); 
        m_currentLineId=m_Gstd.getId(); 
        PageReference returnPage = new PageReference('/a07/e');
        return returnPage;
    }                                          
}

And here's the page:
<apex:page standardController="Order_Line_Item__c" extensions="LineEditExtension">
    <apex:sectionHeader title="{!$ObjectType.Order_Line_Item__c.label} Edit" subtitle="{!Order_Line_Item__c.name}"/>
    <apex:form >
    <apex:pageBlock title="{!$ObjectType.Order_Line_Item__c.label} Edit" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!saveAndNew}" value="Save & New"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection showHeader="true" title="Information" columns="2">
            <apex:inputField required="true" value="{!Order_Line_Item__c.Product__c}"/>
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem />
            <apex:inputField required="true" value="{!Order_Line_Item__c.Order_Number__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Length_of_Subscription__c}"/>
            <apex:pageBlockSectionItem />
            <apex:inputField value="{!Order_Line_Item__c.Year_of_Contract__c}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection showHeader="true" title="Details" columns="2">
            <apex:inputField value="{!Order_Line_Item__c.Quantity__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Type_of_Sale__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Price_per_Unit__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.New_Money__c}"/>
            <apex:inputField value="{!Order_Line_Item__c.Renewal_Increase_money__c}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection showHeader="true" title="System Information" columns="2">
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem />
            <apex:inputField required="true" value="{!Order_Line_Item__c.Name}"/>
            <apex:pageBlockSectionItem />
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Any insight will save my sanity.
Thanks,
KathyBB
  • September 25, 2014
  • Like
  • 0