• Kamatchi Devi R
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

Hi,

 

I have a trigger that auto populate the account owner and a lookup field that refers the user of salesforce account.

Now its working while the user id is matched by comparision in trigger while creating the account.

 

But, I need to auto populate the owner by giving the username directly through data loader. Its showing an error like too many sql Queries: 20001. And i need the way to update the owner and lokup field while giving the name directly.

  

Following is the Trigger for Auto Populating the Account Object fields including  the Owner and Lookup,

 

trigger demo on Account (before insert)
{
List<Account> accountsWithContacts;
Map<Id, String> ownerMap = new Map<Id, String>();
ID mangerid; ID vestid; ID accowner;

 

accountsWithContacts=Trigger.new;
List<Account_Trigger__c> l=[select Id, ACCOUNT_MANAGER__c,AccountOwner__c,Agency_Category__c,Region__c,RegionalRep__c,State__c,SubRegion__c,VEST__c from Account_Trigger__c];
List<AccountTriggerforabove100__c> lt=[select Id, Account_Manager__c,Account_Owner__c,Agency_Category__c,Region__c,Regional_Rep__c,State__c,SubRegion__c,VEST__c from AccountTriggerforabove100__c];
List<User> u=[select Id,Name from User ];

for(Account a:accountsWithContacts)
{
for(Account_Trigger__c at:l)
{
for(User us:u)
{
if(us.Name==a.Account_Manager1__c)
mangerid=(ID)us.Id;
if(us.Name==a.VEST__c)
vestid=(ID)us.Id;
}

if(a.BillingState==at.State__c )
{
if(a.RecordTypeId =='01290000000SUc5' || a.RecordTypeId =='01290000000SUcA' || a.RecordTypeId =='01290000000SUcK' || a.RecordTypeId =='01290000000SUcF' )
{
if(a.Number_of_Officers__c < 100 && a.Number_of_Officers__c > 0)
{
a.Sub_Region__c=at.SubRegion__c;
a.Regional_Rep__c=at.RegionalRep__c;
a.Region__c=at.Region__c;
a.Agency_Category__c=at.Agency_Category__c;
a.OwnerId=accowner;
a.Account_Manager1__c=mangerid;
a.VEST__c=vestid;
}

}
}

}

for(AccountTriggerforabove100__c aa :lt)
{

if(a.BillingState==aa.State__c )
{
if(a.RecordTypeId =='01290000000SUc5' || a.RecordTypeId =='01290000000SUcA' || a.RecordTypeId =='01290000000SUcK' || a.RecordTypeId =='01290000000SUcF' )
{
if(a.Number_of_Officers__c >= 100 )
{
/* User u=[select Id,Name from User where Name=:aa.Account_Owner__c limit 1];
User u1=[select Id,Name from User where Name=:aa.Account_Manager__c limit 1];
User u2=[select Id,Name from User where Name=:aa.VEST__c limit 1];*/
a.Sub_Region__c=aa.SubRegion__c;
a.Regional_Rep__c=aa.Regional_Rep__c;
a.Region__c=aa.Region__c;
a.Agency_Category__c=aa.Agency_Category__c;
a.OwnerId=accowner;
a.Account_Manager1__c=mangerid;
a.VEST__c=vestid;
}

}
}
}
}
}

Here i refer a custom setting object to store the details of account back end.

And OwnerID, Account_Manager1__c and VEST__c are the fields that refers Salesforce User name.

So, please guide me how to update the user name in owner or lookup fields.

 

Thanks in Advance,

Kamatchi Devi R

 

 

 

Hi,

 

I'm in need of displaying table dynamically in force.com site.

And created VF page and controller for this table VF page.

For this, I have a custom object called 'Directory__c" details in my account.

 

 

I created the table in VF page using the following code,

<apex:page controller="directory" showheader="false">
<br/>
<br/>
<apex:panelGrid columns="1" id="theGrid" width="50%" >
<apex:pageBlock >
<apex:form >
<apex:dataTable value="{!dir}" var="dir1" styleClass="list">

<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!dir1.First_Name__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Phone</apex:facet>
<apex:outputText value="{!dir1.Phone_no__c}"/>
</apex:column>

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

 

Controller for the VF page is below,

public class directory {

Directory__c [] dir;
public List<Directory__c > getDir (){
if(dir== null){
dir= [select First_Name__c, Phone_no__c from Directory__c limit 10];
}
return dir;
}

 

}

 

 

The problem was the vf page is getting reflected in Salesforce.com while running as an Apex Vf page.

But, when i add this page to the force.com site and tried to run its not getting reflected.

 

Have anyone know the solution please reply me.

 

 

Thanks in Advance,

Kamatchi Devi.R

 

Hi,

 

I need to create a visual force which is reflected by the Edit Page Layout of an Object.

 

I am trying to find a solution.Help me to find a solution

 

Thanks in advance 

 

 

Hi,

 

I'm in need of displaying table dynamically in force.com site.

And created VF page and controller for this table VF page.

For this, I have a custom object called 'Directory__c" details in my account.

 

 

I created the table in VF page using the following code,

<apex:page controller="directory" showheader="false">
<br/>
<br/>
<apex:panelGrid columns="1" id="theGrid" width="50%" >
<apex:pageBlock >
<apex:form >
<apex:dataTable value="{!dir}" var="dir1" styleClass="list">

<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!dir1.First_Name__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Phone</apex:facet>
<apex:outputText value="{!dir1.Phone_no__c}"/>
</apex:column>

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

 

Controller for the VF page is below,

public class directory {

Directory__c [] dir;
public List<Directory__c > getDir (){
if(dir== null){
dir= [select First_Name__c, Phone_no__c from Directory__c limit 10];
}
return dir;
}

 

}

 

 

The problem was the vf page is getting reflected in Salesforce.com while running as an Apex Vf page.

But, when i add this page to the force.com site and tried to run its not getting reflected.

 

Have anyone know the solution please reply me.

 

 

Thanks in Advance,

Kamatchi Devi.R

 

hello every body,
I am currently working on visual force email template
i want to set a logo in my email but when i do it with the help of htmlEmailBody it shows me txt but not the image
when i send this image using attachment, there i can see my image
can any body guide me how can i add an image in my visualforce email without sending it into attachment?

  • April 18, 2011
  • Like
  • 0
Hi all, I'm trying to run a simple trigger before delete. The error I'm getting is:

System.NullPointerException: Attempt to de-reference a null object


Code:
trigger deleteMultiday on SFDC_Special_Event__c (before delete) {

        for (SFDC_Special_Event__c co : Trigger.new)
        {

        }//end main for

}//end trigger

 I originally had logic in the loop but removed it to see if it was causing the error. But the error is still showing with this code. The above code works perfectly in insert/update triggers.