• Nonick
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 12
    Replies

Hi,

 

I've been having an ongoing problem with eclipse freezing while it's syncing with salesforce to update a current, or start a project. The freeze happens about five seconds into the load after I complete the login details.

 

I'm certain the network proxy settings are correct. Tracking network traffic it looks like its waiting for input from salesforce and hangs. At router, it's still sending out packets, but none are received.

 

Last time I modifying the system, I was using eclipse and plugin for 3.3 but that no longer works with the same crash result., going back historically, last version that works is 3.2.2 but I would like to have some of the newer features.

 

Anyone had a similar problem? This is reasonably urgent as there's code I would love to modify in my system and don't really have a method to do it in production environment.

 

 

I'm looking for a method to format a datestamp field into a dd/mm/yyyy field.
The object we're refferencing is the default Opportunity object.

Currently returns:
Start Date:Tue Nov 25 00:00:00 GMT 2008
Would like it to return:
25/11/2008
The code for this is:
Start Date:{!relatedTo.EngagementStartDate__c}<br />

Anyone have any ideas? Everyone says to use the get, methods on a date, but our sforce resource stated that I can't do that in a template or merge document.

Regards,
N

PS
While we're here, I'd like to also merge in information of the Primary Contact. I know this is a one line requirement that has a whole slew of problems, but my alternative is writing a trigger that populates a new lookup field with the primary contact and using that field to drill to various pieces of information, this is a REALLY cumbersome solution, I'd rather call on the related contact roles list, but accounting the resource, if/else functions don't work on that list.


Message Edited by Nonick on 11-26-2008 05:24 PM
  • November 27, 2008
  • Like
  • 0
Still cutting my teeth on a test method of a reasonably simple trigger I've brought up in the past.

The trigger works fine in sandbox, but doesn't seem to work during the test method, I'm at the end of my wits with it so was hoping somebody with more insight might be willing to check it out:

Code:
public class TestTriggers {
  static testMethod void myTest() {
   Date futureDate = date.newInstance(2050, 6, 6);
    Account account = new Account(name='testAccount', OfficeOwningAccount__c='VIC', Industry='Defence');
    insert account;
    account = [select name from Account where name=:account.name];
    Opportunity opp = new Opportunity(name='testOpp', accountID=account.ID, StageName='1.0 - Territory', CloseDate = futureDate);
    insert opp;
    opp = [select ID, name, StageName, Primary_Contact__c, PricingMethod__c from Opportunity where ID=:opp.ID];
    Contact contact = new Contact(lastname='testContact', accountID=account.ID);
    insert contact;
    contact = [select name from Contact where LastName=:contact.lastname];
    OpportunityContactRole oppContact = new OpportunityContactRole(IsPrimary = true, ContactID=contact.ID, OpportunityID=opp.ID);
    insert oppContact;
    oppContact = [select Id, isPrimary from OpportunityContactRole where OpportunityID=:oppContact.OpportunityID and ContactID=:oppContact.ContactID];
    Practice_Service_Offering__c practiceService = new Practice_Service_Offering__c(Opportunity__c = opp.ID, of_Sale__c = 100);
    insert practiceService;
    practiceService = [select Id from Practice_Service_Offering__c where Opportunity__c = :opp.ID];
    update opp;
    opp.name = 'testOppUpdate';
    opp.StageName = '7.0 - Win';
    opp.ENGAGEMENTSTARTDATE__C = futureDate;
    opp.ENGAGEMENTCLOSEDATE__C = futureDate;
    opp.HOURS_PER_DAY__C = 8;
    opp.PRICINGMETHOD__C = 'Fixed-Price';
    opp.PROPOSED_CONSULTANTS_AGREED_BILLING_RA__C = 'testBillRate';
    opp.AMOUNT = 20000;
//This info is all required fields for something at Stage 7
//When something goes to stage 7, IsClosed switches to true
    update opp;
    opp = [select ID, name, IsClosed, StageName, Primary_Contact__c, PricingMethod__c from Opportunity where ID=:opp.ID];
//Assertions go here:
    System.assert(account != null);
    System.assert(contact != null);
    System.assert(oppContact != null);
    System.assert(practiceService != null);
    System.assert(opp.PricingMethod__c == 'Fixed-Price');
    System.assert(opp.name == 'testOppUpdate');
    System.assert(opp.IsClosed);
    System.assert(opp.Primary_Contact__c != null);
     try {
       delete opp;
       delete account;
       delete oppContact;
       delete contact;
       delete practiceService;
       }
     catch (DmlException e) {
       e.getDmlMessage(0);
       System.assert(false);
     }
 System.assert(opp==null);
    }
}

 
The trigger in question is here
Code:
trigger SetPrimaryContact on Opportunity (before update) {

    for (Opportunity o : Trigger.new) {
     //innitialise variables
     OpportunityContactRole contactRole;
     //Check that the opportunity is being closed out
      if (o.IsClosed && !Trigger.oldMap.get(o.id).IsClosed) {
     contactRole = [select ContactID from OpportunityContactRole where IsPrimary = true and OpportunityId = :o.id];
      }
      //if something is returned from the list:
      //get the primary contact associated with opp and assign the id to primary contact field
    if(contactRole != null){
    o.Primary_Contact__c = contactRole.ContactID;
    }
    //Profit
   }
}

Idea is simple, if an opportunity is closed out, then it pulls the information from related list into the opportunity field. This is a work around due to us having mail merges going out which should contain info from the related list section.

There are 3 failed assertions in the above:
System.assert(false); //from catch statement
System.assert(opp==null); //from just after catch statement (obviously it seems to be having some problems deleting opp)
//The big one
System.assert(opp.Primary_Contact__c != null);

I lightly considered commenting out the assertions and hoping for the best, but something tells me, our Best Practice Rep. would try and choke me out for that.
:smileytongue:

may I also use this opportunity (no pun intended) to point out that
:manvery-happy: and :womanmad: are phenominally creepy.

 

  • November 19, 2008
  • Like
  • 0
I'm just learning how to make triggers and have finally made one that works in dev environment to update a custom lookup field in an opportunity. This is so that in a mail merge I can call details of the billing contact.

Code: Primary Contact Update Field Trigger
trigger SetPrimaryContact on Opportunity (before update) {
   for (Opportunity o : Trigger.new) {
//     if (o.IsClosed && !Trigger.oldMap.get(o.id).IsClosed) {
          OpportunityContactRole contactRole = [select ContactID from OpportunityContactRole where IsPrimary = true and OpportunityId = :o.id];
 

  if (contactRole != null) {
  o.Primary_Contact__c = contactRole.ContactID;
//  }
  }
  }
}

 The reason for the commenting out of that 'if' function is because I have a rather intensive validation process on closed opportunities, I just want to get the thing working at this point without having to create 3 related objects for what should be a simple field update formula.

The test method class is here
Code:TestTriggers class
public class TestTriggers {
  static testMethod void myTest() {
   Date d = date.newInstance(2050, 6, 6);
    Opportunity o = new Opportunity(name='test2', StageName='1.0 - Territory', CloseDate = d);
    insert o;
    o.name = 'test3';
    update o;
    System.assert((o.Primary_Contact__c == null) || (o.Primary_Contact__c != null));
    if(o.Primary_Contact__c != null){
     Contact testC = [select name from Contact where id=:o.Primary_Contact__c];
     System.assert(testC != null);
    }
    System.assert(o.CloseDate == d);
    try {
      delete o;
    } catch (DmlException e) {
      System.assert(false);
    }
 }

}

 The error thrown is a consistant "Average test coverage across all Apex Classes and Triggers is 50%, at least 75% test coverage is required"

And:
"System.DmlException: Update failed. First exception on row 0 with id 00620000006FcQkAAK; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SetPrimaryContact: execution of BeforeUpdate

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.SetPrimaryContact: line 4, column 47    TestTriggers.cls    Primary Contact/src/unpackaged/classes    line 7    Force.com run test failure"

The annoying part is that this error wasn't thrown before.


As an additional question, why does Eclipse throw the error that the trigger xml is not saved, is it not being tested? How does one go about testing
Code:
<—xml version="1.0" encoding="UTF-8"–>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>13.0</apiVersion>
    <status>Active</status>
</ApexTrigger>

 


PS, bump this thread if you are sick of hearing "Work Around"





Message Edited by Nonick on 10-13-2008 10:48 PM

Message Edited by Nonick on 10-13-2008 10:49 PM

Message Edited by Nonick on 10-13-2008 10:50 PM
  • October 14, 2008
  • Like
  • 0
I've got some users who need to share opportunities and accounts. Is it possible to notify the user given additional access rights that the change occured? I can track anything down through workflow, but then again I'm not sure how the sharing model works.

Any help appreciated.
  • October 08, 2008
  • Like
  • 0
Hi all,
Learning visual force at the moment my making a small applet which would allow you to enter two dates and it outputs the the total amount of week days.

Now remember this is made from scratch on a first go, and even then still a pitiful attempt but here is my page:

main
Code: Page
<apex:page controller="dateCalculator">
<apex:form >
<apex:pageBlock title="Date Calculator">
<p>Start Date: <apex:inputField id="StartDate" value="{!o.EngagementStartDate__c}" />:</p>
<p>Close Date: <apex:inputField id="CloseDate" value="{!o.EngagementCloseDate__c}" />:</p>
<apex:commandButton action="{!calculate}" rerender="calculation" value="Go"/>
<apex:outputPanel id="calculation">
<p><apex:outputLabel title="Calculated Amount: " id="lbCalc" value="Output hopefully here" /></p>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>

controller:
Code:
public class dateCalculator {

    private Date startDate;
    private Date closeDate;
    private Opportunity o = new Opportunity();
    private Integer result;
    private Integer formula1;
    private Integer formula2;
   
    public Date getStartDate(){
    return this.startDate;
    }
    public void setStartDate(Date s){
    this.startDate = s;
    }
    public Date getCloseDate(){
    return this.closeDate;
    }
    public void setCloseDate(Date s){
    this.startDate = s;
    }
    public Integer calculateFormula(){
        Date sundayDate = date.newInstance(1985, 6, 24);
        formula1 = closeDate.daysBetween(startDate) + 1;
        formula2 = math.mod(2, 5);
//        CASE(MOD(sundayDate.daysBetween(startDate), 7) , 0
//        , CASE( MOD( closeDate - startDate, 7 ),1,0,2,0,3,0,4,0,5,1,6,2,0 ), 1
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,0,2,0,3,0,4,0,5,2,2 ), 2
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,0,2,0,3,1,2), 3
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,0,2,1,2), 4
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,1,2), 5
//        , CASE( MOD( closeDate - startDate, 7 ),0,1,2), 6
//        , CASE( MOD( closeDate - startDate, 7 ),6,2,1)
//        , 666 )
//        +
//        ( FLOOR( ( closeDate - startDate ) / 7 ) * 2 );
       
        return (formula2 - formula1);
    }
  
    public PageReference calculate() {
        return null;
    }
    public Opportunity getO() {
        return this.o;
    }

}

 the formula is mostly stolen from a different message, the problem is that apparently there's no 'case' operator in apex. What's the work around for this? I was thinking of using a combination of "if/else" and "or" but can't find the OR operator either. Any suggestions?

Also, what would be the best method to display the result, plan above was to change the value of the label and re-render page, any guidance appreciated.

 



Message Edited by Nonick on 09-21-2008 10:56 PM
  • September 22, 2008
  • Like
  • 0

I just installed CMSForce in development as a trail before I go forth with production...

The first 6 steps of the installation process are concerning. We have way too many documents, dashboards, letterheads, workflows etc that we already have set up in Salesforce. I do not want any existing settings changed that would impact their current function.  Can you verify before I install to production? Thanks!

  1. Change the visibility settings for any installed documents, reports, dashboards, letterheads, email templates, and custom fields on standard objects. By default, these components are visible to all users. Set the Running User for any installed dashboards or analytic snapshots; by default, it is set to you.
  2. Set the Running User for any installed dashboards or analytic snapshots; by default, it is set to you.
  3. Specify the appropriate recipients for any installed workflow tasks.
  4. Specify the appropriate assignees for any installed workflow alerts.
  5. Specify the appropriate user for workflow field updates that modify the Owner field or user lookups; by default, it is set to you.
  6. Create a schedule for any installed analytic snapshots.
  7. Configure any additional settings for this package from the package detail page.
  8. Deploy the package by clicking Deploy Now below. You can also do this at any time in the future from the package detail page.
I'm looking for a method to format a datestamp field into a dd/mm/yyyy field.
The object we're refferencing is the default Opportunity object.

Currently returns:
Start Date:Tue Nov 25 00:00:00 GMT 2008
Would like it to return:
25/11/2008
The code for this is:
Start Date:{!relatedTo.EngagementStartDate__c}<br />

Anyone have any ideas? Everyone says to use the get, methods on a date, but our sforce resource stated that I can't do that in a template or merge document.

Regards,
N

PS
While we're here, I'd like to also merge in information of the Primary Contact. I know this is a one line requirement that has a whole slew of problems, but my alternative is writing a trigger that populates a new lookup field with the primary contact and using that field to drill to various pieces of information, this is a REALLY cumbersome solution, I'd rather call on the related contact roles list, but accounting the resource, if/else functions don't work on that list.


Message Edited by Nonick on 11-26-2008 05:24 PM
  • November 27, 2008
  • Like
  • 0
Now that I have created a visual force page in a SANDBOX account I can access it using a URL in the following form: http://mySalesforceInstance/apex/nameOfNewPage .  My problem or question now is how do I publish this to my Salesforce Instance so I can access this type of page for daily use?
 
Thanks for any help!~
  • November 26, 2008
  • Like
  • 0
I want to display a visual force page on my salesforce homepage. However, I can't do that because the height of the page is dynamic, and no matter what I try the homepage components always end up being static. 
 
 My homepage component is this:
<IFRAME id=itarget src="/apex/OSShomepage" frameBorder=0 width="100%" height=400></IFRAME> 
 
Is there something i'm not doing here that would make it dynamic??
 
 
Also, I tried going in a different direction and made a custom home tab that displayed the visual force page. I thought that this would solve the problem because the page itself has no problems. However, when I went to remove the standard home page from the custom app, it said you're not allowed to do this. Then when I went to hide the home tab from peoples profiles, it didn't let me. Is there another way i don't know about?
 
There must be a way to accomplish at least one of these things. Thanks in advance for your help.
 
 
I want to write a trigger that will auto populate a date field when another date field from another object is filled in.  One field is from a custom object the other from a standard Contract object. The account name that is attached to both objects has to match so that the correct date is passed into the field that I have created.
 
So, I want to take a date from the contract object and put it in a field in the custom object, where their accounts match. There is a little hiccup in this that I do not know how to handle. in the standard Contract object the Account field is a standard lookup field. But in the custom object the the Account Name field is a custom field that has a master detail relationship to Account. - how do I deal with that? I just want to make sure that the accounts being referenced in the two different objects are the same Account.
 
Does anyone have an idea of how to start this trigger? or even pseudo code would be helpful because I cannot wrap my head around this right now.
  • November 20, 2008
  • Like
  • 0
Still cutting my teeth on a test method of a reasonably simple trigger I've brought up in the past.

The trigger works fine in sandbox, but doesn't seem to work during the test method, I'm at the end of my wits with it so was hoping somebody with more insight might be willing to check it out:

Code:
public class TestTriggers {
  static testMethod void myTest() {
   Date futureDate = date.newInstance(2050, 6, 6);
    Account account = new Account(name='testAccount', OfficeOwningAccount__c='VIC', Industry='Defence');
    insert account;
    account = [select name from Account where name=:account.name];
    Opportunity opp = new Opportunity(name='testOpp', accountID=account.ID, StageName='1.0 - Territory', CloseDate = futureDate);
    insert opp;
    opp = [select ID, name, StageName, Primary_Contact__c, PricingMethod__c from Opportunity where ID=:opp.ID];
    Contact contact = new Contact(lastname='testContact', accountID=account.ID);
    insert contact;
    contact = [select name from Contact where LastName=:contact.lastname];
    OpportunityContactRole oppContact = new OpportunityContactRole(IsPrimary = true, ContactID=contact.ID, OpportunityID=opp.ID);
    insert oppContact;
    oppContact = [select Id, isPrimary from OpportunityContactRole where OpportunityID=:oppContact.OpportunityID and ContactID=:oppContact.ContactID];
    Practice_Service_Offering__c practiceService = new Practice_Service_Offering__c(Opportunity__c = opp.ID, of_Sale__c = 100);
    insert practiceService;
    practiceService = [select Id from Practice_Service_Offering__c where Opportunity__c = :opp.ID];
    update opp;
    opp.name = 'testOppUpdate';
    opp.StageName = '7.0 - Win';
    opp.ENGAGEMENTSTARTDATE__C = futureDate;
    opp.ENGAGEMENTCLOSEDATE__C = futureDate;
    opp.HOURS_PER_DAY__C = 8;
    opp.PRICINGMETHOD__C = 'Fixed-Price';
    opp.PROPOSED_CONSULTANTS_AGREED_BILLING_RA__C = 'testBillRate';
    opp.AMOUNT = 20000;
//This info is all required fields for something at Stage 7
//When something goes to stage 7, IsClosed switches to true
    update opp;
    opp = [select ID, name, IsClosed, StageName, Primary_Contact__c, PricingMethod__c from Opportunity where ID=:opp.ID];
//Assertions go here:
    System.assert(account != null);
    System.assert(contact != null);
    System.assert(oppContact != null);
    System.assert(practiceService != null);
    System.assert(opp.PricingMethod__c == 'Fixed-Price');
    System.assert(opp.name == 'testOppUpdate');
    System.assert(opp.IsClosed);
    System.assert(opp.Primary_Contact__c != null);
     try {
       delete opp;
       delete account;
       delete oppContact;
       delete contact;
       delete practiceService;
       }
     catch (DmlException e) {
       e.getDmlMessage(0);
       System.assert(false);
     }
 System.assert(opp==null);
    }
}

 
The trigger in question is here
Code:
trigger SetPrimaryContact on Opportunity (before update) {

    for (Opportunity o : Trigger.new) {
     //innitialise variables
     OpportunityContactRole contactRole;
     //Check that the opportunity is being closed out
      if (o.IsClosed && !Trigger.oldMap.get(o.id).IsClosed) {
     contactRole = [select ContactID from OpportunityContactRole where IsPrimary = true and OpportunityId = :o.id];
      }
      //if something is returned from the list:
      //get the primary contact associated with opp and assign the id to primary contact field
    if(contactRole != null){
    o.Primary_Contact__c = contactRole.ContactID;
    }
    //Profit
   }
}

Idea is simple, if an opportunity is closed out, then it pulls the information from related list into the opportunity field. This is a work around due to us having mail merges going out which should contain info from the related list section.

There are 3 failed assertions in the above:
System.assert(false); //from catch statement
System.assert(opp==null); //from just after catch statement (obviously it seems to be having some problems deleting opp)
//The big one
System.assert(opp.Primary_Contact__c != null);

I lightly considered commenting out the assertions and hoping for the best, but something tells me, our Best Practice Rep. would try and choke me out for that.
:smileytongue:

may I also use this opportunity (no pun intended) to point out that
:manvery-happy: and :womanmad: are phenominally creepy.

 

  • November 19, 2008
  • Like
  • 0
Hi all,
Learning visual force at the moment my making a small applet which would allow you to enter two dates and it outputs the the total amount of week days.

Now remember this is made from scratch on a first go, and even then still a pitiful attempt but here is my page:

main
Code: Page
<apex:page controller="dateCalculator">
<apex:form >
<apex:pageBlock title="Date Calculator">
<p>Start Date: <apex:inputField id="StartDate" value="{!o.EngagementStartDate__c}" />:</p>
<p>Close Date: <apex:inputField id="CloseDate" value="{!o.EngagementCloseDate__c}" />:</p>
<apex:commandButton action="{!calculate}" rerender="calculation" value="Go"/>
<apex:outputPanel id="calculation">
<p><apex:outputLabel title="Calculated Amount: " id="lbCalc" value="Output hopefully here" /></p>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>

controller:
Code:
public class dateCalculator {

    private Date startDate;
    private Date closeDate;
    private Opportunity o = new Opportunity();
    private Integer result;
    private Integer formula1;
    private Integer formula2;
   
    public Date getStartDate(){
    return this.startDate;
    }
    public void setStartDate(Date s){
    this.startDate = s;
    }
    public Date getCloseDate(){
    return this.closeDate;
    }
    public void setCloseDate(Date s){
    this.startDate = s;
    }
    public Integer calculateFormula(){
        Date sundayDate = date.newInstance(1985, 6, 24);
        formula1 = closeDate.daysBetween(startDate) + 1;
        formula2 = math.mod(2, 5);
//        CASE(MOD(sundayDate.daysBetween(startDate), 7) , 0
//        , CASE( MOD( closeDate - startDate, 7 ),1,0,2,0,3,0,4,0,5,1,6,2,0 ), 1
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,0,2,0,3,0,4,0,5,2,2 ), 2
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,0,2,0,3,1,2), 3
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,0,2,1,2), 4
//        , CASE( MOD( closeDate - startDate, 7 ),0,0,1,1,2), 5
//        , CASE( MOD( closeDate - startDate, 7 ),0,1,2), 6
//        , CASE( MOD( closeDate - startDate, 7 ),6,2,1)
//        , 666 )
//        +
//        ( FLOOR( ( closeDate - startDate ) / 7 ) * 2 );
       
        return (formula2 - formula1);
    }
  
    public PageReference calculate() {
        return null;
    }
    public Opportunity getO() {
        return this.o;
    }

}

 the formula is mostly stolen from a different message, the problem is that apparently there's no 'case' operator in apex. What's the work around for this? I was thinking of using a combination of "if/else" and "or" but can't find the OR operator either. Any suggestions?

Also, what would be the best method to display the result, plan above was to change the value of the label and re-render page, any guidance appreciated.

 



Message Edited by Nonick on 09-21-2008 10:56 PM
  • September 22, 2008
  • Like
  • 0
Hi,

Is it possible to throw a new System.DmlException from a trigger. I need to create a complex validation rule that can't be done with the normally defined custom validation rules.

Thanks for any help!


Message Edited by Scott.M on 09-17-2008 07:41 AM
  • September 11, 2008
  • Like
  • 0
Hi,
 
I want to create a clone copy of standard object - Account and all the associated validation rules in S-Control.
Is it possible to clone the standard object using AJAX or any other way in S-Control ?
 
 
Thanks
Rameshwar