• kle
  • NEWBIE
  • 135 Points
  • Member since 2012

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

i am writing a test for my controller for that i have to insert event in test database my test method is

static TestMethod void Test1_TestInsertWithValue()
{Meeting_Master__c master=new Meeting_Master__c();
Event event =new Event();
Profile p=[SELECT Id From Profile WHERE Name='Standard User'];
User u2 =new User(Alias = 'newUser' , Email ='newuser@testorg.com' , EmailEncodingKey = 'UTF-8' , LastName = 'Testing',
LanguageLocaleKey='en_US',LocaleSidKey='America/Los_Angeles', UserName='newuser@testorg.com',ProfileId=p.Id);

event.OwnerId =u2.Id;
event.StartDateTime =datetime.newInstance(2008, 12, 1);
event.EndDateTime = datetime.newInstance(2008,12,30);
event.subject='call';
event.WhatId=master.Id;
insert master;
insert event;
...........
}

when insert event occur i am facing error System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]

how to rectify this error??

Hello,

 

I have a Picklist in which one of the fields is "Error". On a user changing form fields and choosing to choose a different picklist value I want a validation rule to check the previous value of the picklist field and to only allow certain values to be picked if previously at "Error".  I have tried the following.

 

OR(AND(PRIORVALUE(Request_Status__c)='Error' , Request_Status__c<>'Draft Request'),AND(PRIORVALUE(Request_Status__c)='Error' , Request_Status__c<>'Endorse'))

 

I receive an error as follows:

Error: Field Request_Status__c is a picklist field. Picklist fields are only supported in certain functions. Tell me more

 

The "Tell me More" link brings me to teh following article  https://avaya--c4rdev.cs12.my.salesforce.com/help/doc/user_ed.jsp?loc=help&target=tips_on_building_formulas.htm%23picklists_and_msps&section=Customizing

 

In which it states "

  • PRIORVALUE(Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the trigger type is set to Every time a record is created or edited)"

I do want this to run though every time an edit occurs though so figured it should work.

 

Does anyone happen to know from looking at the above what I may be doing wrong and a way to get around this?

 

Thanks in advance.


I'm developing in a sandbox that just got the Spring '12 Preview and I've noticed two things:

 

1) When using the Developer Console, I can no longer see the execution log (or anything but the log file itself) when a log is created, unless I create the log from the "execute" field.

 

Here's a picture of what the a normal log looks like when I open it:

 

http://screencast.com/t/HGXLZ6BxGm

 

And here's what the log looks like when I run code from the execute field (and how I WISH it looked like all the time).

 

http://screencast.com/t/3UiKE58RXw

 

2) The Developer Mode section shows up but I can never get the code to display, and even if I check the "view state" checkbox on my user record it never shows up:

 

http://screencast.com/t/BrHeOHC0

 

Anyone having this same issue, or have any idea what could be going on?  This was all working on Friday, which I believe was before the Spring 12 preview.

 

Thanks,

 Drew

trigger AddQuickLead on Lead (after insert) {
    
    for (Lead l : Trigger.new) {
       
        
        Quick_Lead__c reg = new Quick_Lead__c(
            Name=l.Name,
            Email__c = l.Email,
            Street_Address__c = l.Street,
            city__c = l.City,
            state__c = l.State,
            Country__c = l.Country
          );
          
          if(l.FirstName==null)
        {
        reg.Name= l.LastName;
        }
        else
        {
        reg.Name= l.FirstName+''+''+l.LastName;
        }
        
        insert reg;
    }

 how to get coverage for line:

reg.Name= l.FirstName+''+''+l.LastName;

i am writing a test for my controller for that i have to insert event in test database my test method is

static TestMethod void Test1_TestInsertWithValue()
{Meeting_Master__c master=new Meeting_Master__c();
Event event =new Event();
Profile p=[SELECT Id From Profile WHERE Name='Standard User'];
User u2 =new User(Alias = 'newUser' , Email ='newuser@testorg.com' , EmailEncodingKey = 'UTF-8' , LastName = 'Testing',
LanguageLocaleKey='en_US',LocaleSidKey='America/Los_Angeles', UserName='newuser@testorg.com',ProfileId=p.Id);

event.OwnerId =u2.Id;
event.StartDateTime =datetime.newInstance(2008, 12, 1);
event.EndDateTime = datetime.newInstance(2008,12,30);
event.subject='call';
event.WhatId=master.Id;
insert master;
insert event;
...........
}

when insert event occur i am facing error System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]

how to rectify this error??

How do we write a test apex for a trigger that creates a child record when a parent record is created? 

 

 

trigger AutoCreateInterviewer on Position__c (after insert) {
    List<Interviewer__c> interviewers = new List<Interviewer__c>();

    //For each position processed by the trigger, add a new  
    //interviewer record for the specified hiring manager.  
    //Note that Trigger.New is a list of all the new positions  
    //that are being created.  
    
    for (Position__c newPosition: Trigger.New) {
        if (newPosition.Hiring_Manager__c != null) {
            interviewers.add(new Interviewer__c(
                        Name = '1',
                        Position__c = newPosition.Id,
                        Employee__c = newPosition.Hiring_Manager__c,
                        Role__c = 'Managerial'));
        }
    }
    insert interviewers;
}

I have a customer using Milestones PM.  They have a Salesforce Platform User that is the owner of a Project records and they can't use the clone button as it says they have insufficient privledges.  The profile gives them full access to this object.  Is there something else that needs to be set?

 

Thanks!

Is there any tutorial where I can learn all about quotas? I'm not sure about its functionality or relationship with the Opportunities.

Hello,

 

I have a Picklist in which one of the fields is "Error". On a user changing form fields and choosing to choose a different picklist value I want a validation rule to check the previous value of the picklist field and to only allow certain values to be picked if previously at "Error".  I have tried the following.

 

OR(AND(PRIORVALUE(Request_Status__c)='Error' , Request_Status__c<>'Draft Request'),AND(PRIORVALUE(Request_Status__c)='Error' , Request_Status__c<>'Endorse'))

 

I receive an error as follows:

Error: Field Request_Status__c is a picklist field. Picklist fields are only supported in certain functions. Tell me more

 

The "Tell me More" link brings me to teh following article  https://avaya--c4rdev.cs12.my.salesforce.com/help/doc/user_ed.jsp?loc=help&target=tips_on_building_formulas.htm%23picklists_and_msps&section=Customizing

 

In which it states "

  • PRIORVALUE(Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the trigger type is set to Every time a record is created or edited)"

I do want this to run though every time an edit occurs though so figured it should work.

 

Does anyone happen to know from looking at the above what I may be doing wrong and a way to get around this?

 

Thanks in advance.


I'm developing in a sandbox that just got the Spring '12 Preview and I've noticed two things:

 

1) When using the Developer Console, I can no longer see the execution log (or anything but the log file itself) when a log is created, unless I create the log from the "execute" field.

 

Here's a picture of what the a normal log looks like when I open it:

 

http://screencast.com/t/HGXLZ6BxGm

 

And here's what the log looks like when I run code from the execute field (and how I WISH it looked like all the time).

 

http://screencast.com/t/3UiKE58RXw

 

2) The Developer Mode section shows up but I can never get the code to display, and even if I check the "view state" checkbox on my user record it never shows up:

 

http://screencast.com/t/BrHeOHC0

 

Anyone having this same issue, or have any idea what could be going on?  This was all working on Friday, which I believe was before the Spring 12 preview.

 

Thanks,

 Drew