• ppat
  • NEWBIE
  • 0 Points
  • Member since 2005

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 22
    Replies
I have a trigger which validates based on the user profile Id. Trigger works fine in sandbox. How do I write test case to evaluate different profiles as test class always finds my profile id while executing the trigger

if (UserInfo.getProfileId()  != 'Salesforce Administrator') // used Id to compare
{
// Code here
}

any pointers would be great.

  • May 28, 2008
  • Like
  • 0
I have following simple trigger to populate one field from account.

When I convert the lead and create new opportunity , this trigger does not get fired .. However if I change something in opportunity after creation , trigger gets fired and this is due to  before update. I also tried to insert opportunity directly and trigger is working as expected

Seems like "before insert" is not working after lead conversion to opportunity

Is there any limitation of the Triggers that it does not get fired when lead is converted ? Can someone please let me know if there is a workaround ?

trigger OpportunityInsert on Opportunity (before insert,before update)
{
    for (Opportunity o : Trigger.new)
    {
        if (o.regpartner != NULL)
        {
               //dc --> Distributor Center
                Account dc = [Select Id, oc from Account where id = :o.regpartner];
             
                    o.oc = dc.oc;
}}}
  • April 23, 2008
  • Like
  • 0
I am trying to add Opportunity Sales Team through Apex. Trigger works fine except "OpportunityAccessLevel" field.

Here is the error : Field is not writeable: OpportunityAccessLevel

If I insert the record without specifying the OpportunityAccessLevel = 'Read/Write'  , default values is getting assigned as OpportunityAccessLevel = 'Read Only'.  I need to assign value OpportunityAccessLevel = 'Read/Write' while adding sales team member.

Any workaround ?

Thanks

Pramod

  • March 24, 2008
  • Like
  • 0
I have created 2 custom objects, Quotes and Parts. (Parts being line items for quotes). I created merge template with custom fields. But I am having parts field empty. Concept is similar to Opportunity and Opportunity Lines Items in which you can use mail merge to create document.

Already ran my scenario through support. Response is "This is not possible with mail merge".

Anybody has done this before?? What are my alternatives??

Found another thread similar to what I am trying to do.

http://forums.sforce.com/sforce/board/message?board.id=general_development&message.id=2848

Is there any progress from salesforce side on this?? Thread is dated back to early 2005.

Thanks

Pramod

Message Edited by ppat on 02-01-2006 10:17 AM

  • February 01, 2006
  • Like
  • 0

Hi All ,

I am new to salesforce and programming. I am trying to Batch insert/update accounts using C#. Can someone please provide me a sample code which will do batch insert or updates?? I have gone through the sample examples but it inserts only one record. I am not sure how to use querymore ,batchsize , queryoptions etc

My source is SQL server database.

Please help !!

 

 

 

  • June 14, 2005
  • Like
  • 0

Dear All,

I am new to salesforce .I am trying to load approximatly 2000 accounts through .net coding. can someone provide .net (C#) code to load accounts in a batch of 200 ??

Thanks a lot for all your help.

P

 

 

  • May 27, 2005
  • Like
  • 0

I have a field called "Division Type" under account view. I would like to show SAME FIELD on opportunity view without duplicating data or field.

is there a way to achieve this ??

Thanks

Pat

 

 

 

  • April 26, 2005
  • Like
  • 0

Scenario  :

Account Name : IBM

Division Imaging  Primary Sales Person : Joe Smith

Division Telecom Primary Sales Person : Anna Barry

In words, Joe Smith and Anna Barry works as a Sales Rep for manuafacturing organization ABC. ABC has Various production divisions like Imaging,  Telecom etc. sales reps are representing corresponding divisions.

Both sales reps are working on 2 different opportunities with IBM. Each division identifies IBM as its own primary account.

How do I show same account under both user's "My Account View" or "My Team's View" ?? Is there a concept called Division in salesforce ??

is there any easy way to create a view with "My Teams" Visibility view ?? If I try to create a view , I only have following option,

Restrict the set of information being searched
All Accounts    My Accounts

Thanks

 

 

 

Message Edited by ppat on 04-06-2005 03:21 PM

  • April 06, 2005
  • Like
  • 0
I have a trigger which validates based on the user profile Id. Trigger works fine in sandbox. How do I write test case to evaluate different profiles as test class always finds my profile id while executing the trigger

if (UserInfo.getProfileId()  != 'Salesforce Administrator') // used Id to compare
{
// Code here
}

any pointers would be great.

  • May 28, 2008
  • Like
  • 0
Hi,
 
Is it possible to check the user who is performing update on any account pages is System Administrator or something else?
I used the below code but failed to show the particular user role who is performing the  update on each Account page. It keeps getting changed,when i do update as the same role(system admin)
Code:
trigger tocAccountTrigger on Account (before update) {
for (Profile p : [select name from Profile])
if(p.name=='System Administrator')
{
//do something
}
}

 
  • May 28, 2008
  • Like
  • 0
Is there a way to run unit tests as a different user? I would like to test validation logic setup for different profiles.

thanks,
ken
I've built a simple trigger that will stop an update to a record based on a user's profile.  In building a test method for this trigger, I don't see any way to simulate both sides of the processing, since the logic in the trigger is dependant on the results of the getUserInfo calls. 
 
The issue, is how to get to 100% code coverage in a test method in this sort of situation?
 
What I'd like to be able to do in my test method is the following:
 
using my current admin login,
update 200 records  (These would succeed, as the admin profile is allowed to make the updates)
 
switch login to a non-admin user login
update 200 records (These would not succeed, and the addError would be applied to the appropriate fields)
 
Jon Keener
 
I have following simple trigger to populate one field from account.

When I convert the lead and create new opportunity , this trigger does not get fired .. However if I change something in opportunity after creation , trigger gets fired and this is due to  before update. I also tried to insert opportunity directly and trigger is working as expected

Seems like "before insert" is not working after lead conversion to opportunity

Is there any limitation of the Triggers that it does not get fired when lead is converted ? Can someone please let me know if there is a workaround ?

trigger OpportunityInsert on Opportunity (before insert,before update)
{
    for (Opportunity o : Trigger.new)
    {
        if (o.regpartner != NULL)
        {
               //dc --> Distributor Center
                Account dc = [Select Id, oc from Account where id = :o.regpartner];
             
                    o.oc = dc.oc;
}}}
  • April 23, 2008
  • Like
  • 0
I am unable to code easily, the following logic.
 
--> Query the batch of Leads to find if the campaign member already exists for them 
--->  If it does not exist, Create One.
 
The issue i see is that: The SOQL select in a for loop, returns only selected rows. If we want to work on those "not matched" I cannot utilize that result.
Ex1: (does not work)
Code:
for(campaign c : [select id from campaign where id in : leadIdList]){
 if c[i].id == null)
  // Do some action such as create a campaign member record.
 i++;
}

Even if you use another coding logic as below, It does not work. since it crosses the SOQL (governers limit) for leads
Ex2: (does notwork)
Code:
for(Lead ld: Trigger.new){ 
   if([select count() from Campaign where id in: leadidList] <= 0){
   //Do some action such as create a campaign member record and store in a list
   }
}
//Then insert all newly created campaign member records at once.
insert xxxx;

 
I bet there is a solution, that I am unable to use here.
 
Thanks in advance.
I am trying to add Opportunity Sales Team through Apex. Trigger works fine except "OpportunityAccessLevel" field.

Here is the error : Field is not writeable: OpportunityAccessLevel

If I insert the record without specifying the OpportunityAccessLevel = 'Read/Write'  , default values is getting assigned as OpportunityAccessLevel = 'Read Only'.  I need to assign value OpportunityAccessLevel = 'Read/Write' while adding sales team member.

Any workaround ?

Thanks

Pramod

  • March 24, 2008
  • Like
  • 0
I'm fairly new to this but trying to learn using the available documentation.  Hopefully this question is not too "large" to be answered on here.

My question:  After creating a custom object (let's call it "Asset" in this example), how can I make it so that when creating a new item (as in using the "Create New..." drop-down on the left pane of Salesforce), only a picklist is given...which then gives a layout depending on the option chosen from the picklist?

A walkthrough of what I'm trying to do:

1. User clicks on Create New... drop-down on left side

2. Choose "Asset"

3.  A picklist pops up with options for Asset Types (PC, monitor, printer)

4.  User chooses printer

5.  A layout is automatically given with fields specific for creating/tracking a printer

Any pointers/advice on how to do this?  Any help would be GREATLY appreciated.  Thanks!!

I am curious which javascript frameworks are hosted on Salesforce servers.  I have found dojo, which I am currently using, but I am very interested in using Mochikit and/or Scriptaculous.  Are either of these currently hosted on SF's servers?  If not, could they be?
Hi,
 
I created 2 custom objects - Quote and Quote line items, similar to Opportunity and Opportunity line items.
 
While using salesforce mail merge, is there any way i can print all Quote line items related to a Quote as all opportunity poducts are listed?
 
Thanks,
 
  • March 11, 2006
  • Like
  • 0

Hi All ,

I am new to salesforce and programming. I am trying to Batch insert/update accounts using C#. Can someone please provide me a sample code which will do batch insert or updates?? I have gone through the sample examples but it inserts only one record. I am not sure how to use querymore ,batchsize , queryoptions etc

My source is SQL server database.

Please help !!

 

 

 

  • June 14, 2005
  • Like
  • 0

Dear All,

I am new to salesforce .I am trying to load approximatly 2000 accounts through .net coding. can someone provide .net (C#) code to load accounts in a batch of 200 ??

Thanks a lot for all your help.

P

 

 

  • May 27, 2005
  • Like
  • 0

I have a field called "Division Type" under account view. I would like to show SAME FIELD on opportunity view without duplicating data or field.

is there a way to achieve this ??

Thanks

Pat

 

 

 

  • April 26, 2005
  • Like
  • 0
I am unable to set up Workflow Rules for custom objects using the SalesForce.com UI because the "Type of Record" drop-down is only populated with pre-defined SalesForce.com objects. Am I missing a step, or are Workflow Rules only for pre-defined objects?