• rgard23
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 9
    Replies
I was just at the Tour de Force - I saw the "Build any UI for Any App Using Visualforce" demo and I'm wondering: how did the presenter store those code snippets? He was dragging and dropping them in, it looked like the library was inside Eclipse.

I've seen the Snippet window in Elicpse, but it looked like he was accessing a prebuilt library of snippets. I'd love to be able ot store my own code blocks, but I couldn't figure out how.

If anyone knows how to add them, I'd appreciate it (meanwhileI'll go search Eclipse's site)

Thanks

[Update]
Okay - I've managed to figure out that I needed to add a "category" to the Snippet window, then I can add items. I just added a new item and put the snippet code I want handy into the "template" text area and it seems to work.

Is there any reason to use the 'variables' options when adding a new 'template'? Thanks again!


Message Edited by icemft1976 on 04-24-2008 02:16 PM

This seems easy enough, but it has me stumped.

 

Use Case: Partners create leads in the partner portal. When the lead is ready to convert, our reps change themselves to the owner and convert it. I want to automatically add (since they forget all the time) the partner user to the sales team.

 

Problem: When I convert the lead (i have the trigger running after insert) I get an error saying that the record is locked.

 

It looks to me like Salesforce inserts the opportunity record, but locks it so its uneditable through the conversion. My trigger also depends on a custom field being mapped over, so that's why I run the trigger after insert so that the field will be mapped over.

 

Any thoughts anyone on how to get around this?

 

Here's my code:

 

 trigger addPartnerToSalesTeam on Opportunity (after insert) {
    
    /**
    * Need to get the opportunity and user
    */
    private Opportunity[] newOpty = new Opportunity[1];
    newOpty = Trigger.new;    

    //get userId of lead creator
    String leadCreatorId = newOpty[0].Lead_Creator_Id__c;

    //get lead Creator profile Id
    User leadCreator = [select profileId from user where id =:leadCreatorId];
    
    newOpty[0].description = leadCreator.ProfileId;//testing
    
    //run trigger if the owner of the converted lead was a partner user
    if(leadCreator.ProfileId == '00e20000000uCnj') {
        newOpty[0].description = newOpty[0].description + ' It works!!!' + ' ' + leadCreatorId; //for testing
        addtoSalesTeam.addUser(newOpty[0], leadCreatorId);

    }//end if

        
}//end addPartnerToSalesTeam trigger

 ________________________________________________________________

 public class addToSalesTeam {
    
    /**
    * To run this method, the trigger (or whatever calls it) must pass two variables:
    *
    * @Opportunity opty = the opportunity being shared
    * @User theUser = the user to be shared with
    *
    */
    public static void addUser (Opportunity opty, String userId) {
        
        OpportunityTeamMember optyMemb = new OpportunityTeamMember();

        optyMemb.OpportunityId = opty.Id;       

        optyMemb.UserId = userId;     

        Database.Saveresult sr = Database.insert(optyMemb);

    }//end addPartner method

}//end AddToSalesTeam

This seems easy enough, but it has me stumped.

 

Use Case: Partners create leads in the partner portal. When the lead is ready to convert, our reps change themselves to the owner and convert it. I want to automatically add (since they forget all the time) the partner user to the sales team.

 

Problem: When I convert the lead (i have the trigger running after insert) I get an error saying that the record is locked.

 

It looks to me like Salesforce inserts the opportunity record, but locks it so its uneditable through the conversion. My trigger also depends on a custom field being mapped over, so that's why I run the trigger after insert so that the field will be mapped over.

 

Any thoughts anyone on how to get around this?

 

Here's my code:

 

 trigger addPartnerToSalesTeam on Opportunity (after insert) {
    
    /**
    * Need to get the opportunity and user
    */
    private Opportunity[] newOpty = new Opportunity[1];
    newOpty = Trigger.new;    

    //get userId of lead creator
    String leadCreatorId = newOpty[0].Lead_Creator_Id__c;

    //get lead Creator profile Id
    User leadCreator = [select profileId from user where id =:leadCreatorId];
    
    newOpty[0].description = leadCreator.ProfileId;//testing
    
    //run trigger if the owner of the converted lead was a partner user
    if(leadCreator.ProfileId == '00e20000000uCnj') {
        newOpty[0].description = newOpty[0].description + ' It works!!!' + ' ' + leadCreatorId; //for testing
        addtoSalesTeam.addUser(newOpty[0], leadCreatorId);

    }//end if

        
}//end addPartnerToSalesTeam trigger

 ________________________________________________________________

 public class addToSalesTeam {
    
    /**
    * To run this method, the trigger (or whatever calls it) must pass two variables:
    *
    * @Opportunity opty = the opportunity being shared
    * @User theUser = the user to be shared with
    *
    */
    public static void addUser (Opportunity opty, String userId) {
        
        OpportunityTeamMember optyMemb = new OpportunityTeamMember();
        
        //put acctId into optyMemb object
        optyMemb.OpportunityId = opty.Id;
        
        //put userId into optyMemb object
        optyMemb.UserId = userId;
        
        //Insert sharing record into database
        Database.Saveresult sr = Database.insert(optyMemb);

    }//end addPartner method

}//end AddToSalesTeam

I am using <apex:inputField> tag in a Visualforce page to render a User lookup field on a custom object. However, unlike the standard Edit screen the VF page doesn't render the picklist that's in front of the lookup fild which promts for type of user (User or Partner User). Basically, no partner users can be selected from the VF page.

 

Is this a known limitation of inputField component? Or am I missing a setting of some sort?

 

Thanks in advance.

 

 

This seems easy enough, but it has me stumped.

 

Use Case: Partners create leads in the partner portal. When the lead is ready to convert, our reps change themselves to the owner and convert it. I want to automatically add (since they forget all the time) the partner user to the sales team.

 

Problem: When I convert the lead (i have the trigger running after insert) I get an error saying that the record is locked.

 

It looks to me like Salesforce inserts the opportunity record, but locks it so its uneditable through the conversion. My trigger also depends on a custom field being mapped over, so that's why I run the trigger after insert so that the field will be mapped over.

 

Any thoughts anyone on how to get around this?

 

Here's my code:

 

 trigger addPartnerToSalesTeam on Opportunity (after insert) {
    
    /**
    * Need to get the opportunity and user
    */
    private Opportunity[] newOpty = new Opportunity[1];
    newOpty = Trigger.new;    

    //get userId of lead creator
    String leadCreatorId = newOpty[0].Lead_Creator_Id__c;

    //get lead Creator profile Id
    User leadCreator = [select profileId from user where id =:leadCreatorId];
    
    newOpty[0].description = leadCreator.ProfileId;//testing
    
    //run trigger if the owner of the converted lead was a partner user
    if(leadCreator.ProfileId == '00e20000000uCnj') {
        newOpty[0].description = newOpty[0].description + ' It works!!!' + ' ' + leadCreatorId; //for testing
        addtoSalesTeam.addUser(newOpty[0], leadCreatorId);

    }//end if

        
}//end addPartnerToSalesTeam trigger

 ________________________________________________________________

 public class addToSalesTeam {
    
    /**
    * To run this method, the trigger (or whatever calls it) must pass two variables:
    *
    * @Opportunity opty = the opportunity being shared
    * @User theUser = the user to be shared with
    *
    */
    public static void addUser (Opportunity opty, String userId) {
        
        OpportunityTeamMember optyMemb = new OpportunityTeamMember();

        optyMemb.OpportunityId = opty.Id;       

        optyMemb.UserId = userId;     

        Database.Saveresult sr = Database.insert(optyMemb);

    }//end addPartner method

}//end AddToSalesTeam

This seems easy enough, but it has me stumped.

 

Use Case: Partners create leads in the partner portal. When the lead is ready to convert, our reps change themselves to the owner and convert it. I want to automatically add (since they forget all the time) the partner user to the sales team.

 

Problem: When I convert the lead (i have the trigger running after insert) I get an error saying that the record is locked.

 

It looks to me like Salesforce inserts the opportunity record, but locks it so its uneditable through the conversion. My trigger also depends on a custom field being mapped over, so that's why I run the trigger after insert so that the field will be mapped over.

 

Any thoughts anyone on how to get around this?

 

Here's my code:

 

 trigger addPartnerToSalesTeam on Opportunity (after insert) {
    
    /**
    * Need to get the opportunity and user
    */
    private Opportunity[] newOpty = new Opportunity[1];
    newOpty = Trigger.new;    

    //get userId of lead creator
    String leadCreatorId = newOpty[0].Lead_Creator_Id__c;

    //get lead Creator profile Id
    User leadCreator = [select profileId from user where id =:leadCreatorId];
    
    newOpty[0].description = leadCreator.ProfileId;//testing
    
    //run trigger if the owner of the converted lead was a partner user
    if(leadCreator.ProfileId == '00e20000000uCnj') {
        newOpty[0].description = newOpty[0].description + ' It works!!!' + ' ' + leadCreatorId; //for testing
        addtoSalesTeam.addUser(newOpty[0], leadCreatorId);

    }//end if

        
}//end addPartnerToSalesTeam trigger

 ________________________________________________________________

 public class addToSalesTeam {
    
    /**
    * To run this method, the trigger (or whatever calls it) must pass two variables:
    *
    * @Opportunity opty = the opportunity being shared
    * @User theUser = the user to be shared with
    *
    */
    public static void addUser (Opportunity opty, String userId) {
        
        OpportunityTeamMember optyMemb = new OpportunityTeamMember();
        
        //put acctId into optyMemb object
        optyMemb.OpportunityId = opty.Id;
        
        //put userId into optyMemb object
        optyMemb.UserId = userId;
        
        //Insert sharing record into database
        Database.Saveresult sr = Database.insert(optyMemb);

    }//end addPartner method

}//end AddToSalesTeam

I was just at the Tour de Force - I saw the "Build any UI for Any App Using Visualforce" demo and I'm wondering: how did the presenter store those code snippets? He was dragging and dropping them in, it looked like the library was inside Eclipse.

I've seen the Snippet window in Elicpse, but it looked like he was accessing a prebuilt library of snippets. I'd love to be able ot store my own code blocks, but I couldn't figure out how.

If anyone knows how to add them, I'd appreciate it (meanwhileI'll go search Eclipse's site)

Thanks

[Update]
Okay - I've managed to figure out that I needed to add a "category" to the Snippet window, then I can add items. I just added a new item and put the snippet code I want handy into the "template" text area and it seems to work.

Is there any reason to use the 'variables' options when adding a new 'template'? Thanks again!


Message Edited by icemft1976 on 04-24-2008 02:16 PM