• pankaj.raijade
  • NEWBIE
  • 285 Points
  • Member since 2011

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 119
    Replies

Is there a way in apex to know what record types the logged in user has access to on particular object?

Thanks.

Hi,  my trigger only fires for the first record in the batch when performing a dataloader insert.  Any ideas on how to get it to fire for all the records in each batch?  Dataloader is set to batchs of 200.  I don't want to reduce the batch to a count of 1, I need it to do bulk.  The trigger is designed to perform a vlookup (using the zip code on the lead as a reference) on a custom object (Postal Code Test)  and populate a custom field on the Lead object.  Each record on the Postal Code Test object contains a zip code and a corresponding internal territory.

 

here's the trigger:

 

trigger UpdateLeadAreaAssign on Lead (before Insert, before Update) {

    try {

        for(Lead x : Trigger.New) {

            //set to no area until it finds a territory matching the zip

            x.Lead_Territory_Trigger__c = 'NOAREA';

           

            //fetch territory from custom object using postal code from lead

            List<Postal_Code_Test__c> triggerLeadArea =

                [SELECT p.Lead_Territory__c

                FROM Postal_Code_Test__c p

                WHERE Zip_Code__c =: x.PostalCode

                LIMIT 1];

           

            //update lead territory field on lead

            x.Lead_Territory_Trigger__c = triggerLeadArea[0].Lead_Territory__c;       

        }

    } 

    catch (Exception e) {      

        System.Debug('ERROR: ' + e);

    }

}

I need to loop through one (and more) related lists of a custom object.  The related lists are also custom objects.

 

Any help on the basic code structure?  How do I identify the records only associated with the current object, then loop through them and, for example, assign records of that related list to a variable, which I in turn update the parent object.   In essence creating a trigger "roll-up" function to a custom object and its related list records.

  • October 11, 2011
  • Like
  • 0

Hi guys, I have 3 lead forms that I created. Lead form 1, 2 and 3. For each lead created when the form is created, I would want to set a conversion rule. For instance, if Lead form 1 is converted, I want account type 1 created. 

 

What is the best way to go about creating this?

 

Thanks

 

Stadler

 

Hi! 

 

I have a custom link that points to an external URL.  I wan to pass a parameter on the URL that tells me when the request is coming from a sandbox vs. our production SFDC environment (so I can handle the request differently).  I'm trying to do this by adding a merge field to the URL, but can't find any available fields that would help me.  I was hoping for something like 'Sandbox Name' or 'Site URL', but really am interested in anything that would help me tell what environment the call comes from.

 

I am doing this currently by hard coding the URL, but the problem is that whenever we refresh our sandbox from production, the production hard coded URL is copied down to the sandbox, and I have to remember to change it manually.  I was thinking a merge field would be a better solution, if I can find something useful.  But I'm open to other ways to do this too.

 

Thanks in advance for your help!

 

  • September 23, 2011
  • Like
  • 0

Hi,

 Can anyone please help me in implimenting a functionallity. I want to delete multiple records from apex page block table, using apex checkboxes.All checked checkboxes must get deleted on click of a single button "mass delete".The visualforce code of my page is given below, need  help in method.Thanks in advance...

<apex:page Controller="TeamMemberAssignmentController" >
 <apex:sectionHeader title="Edit Records"/>
  <apex:form >
    <apex:pageBlock mode="inlineEdit" id="block">
        <apex:pageMessages />
        <apex:pageBlockSection >
            <apex:outputLabel value="User" for="searchUser"/>
            <apex:inputField value="{!accTeamMem.UserId}" id="searchName" required="false"/>
            <apex:outputLabel value="Account" for="searchAccount"/>
            <apex:inputField value="{!accTeamMem.AccountId}" id="searchAccount" required="false"/>
            <apex:outputLabel value="Role" for="searchRole"/>
            <apex:inputField value="{!accTeamMem.TeamMemberRole}" id="searchRole" required="false"/>
            

            <apex:commandButton value="Search" action="{!search}" rerender="block" status="status"/>
            <apex:commandButton value="Save"  action="{!save}" id="saveButton" rerender="block" status="status1"/>
         <apex:commandButton action="{!update1}"  id="editButton" value="Edit And Save"   />
        <apex:commandButton action=""  id="DeleteButton" value="Delete"   />

                           
         </apex:pageBlockSection><br/>


        <apex:actionStatus id="status" startText="Searching... please wait..."/>
         <apex:actionStatus id="status1" startText="Saving your record... please wait..."/>
              
              

                     <apex:pageBlockSection title="Search Results" id="resultsBlock" columns="2">
        <apex:pageBlockTable value="{!searchResults}" var="AccountTeamMember" rendered="{!NOT(ISNULL(searchResults))}">
         
       

                 


          <apex:column >
      <!-- <apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;-->
       <a href="javascript&colon;if (window.confirm('Are you sure?')) DeleteAccount('{!AccountTeamMember.Id}');" style="font-weight:bold">Del</a>
     </apex:column>

             <apex:column HeaderValue="Mass Delete">
                     <apex:inputCheckbox title="mass delete" value="{!AccountTeamMember.Id}" />
             </apex:column>

    
          <apex:column value="{!AccountTeamMember.User.Name}" headerValue="User" width="100"/>
          <apex:column value="{!AccountTeamMember.Account.Name}" headerValue="Account" width="100"/>
                      <apex:column headerValue="Role" width="200">
 

            <apex:outputField value="{!AccountTeamMember.TeamMemberRole}">
             <apex:inlineEditSupport showOnEdit="saveButton, cancelButton,editButton" 
                        event="ondblclick" 
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>

 



            </apex:outputfield>
            </apex:column>
        </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>




<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
   <apex:param name="accountteammemberid" value="" assignTo="{!SelectedAccountTeamMemberId}"/>
</apex:actionFunction>

  </apex:form>
</apex:page>

 i have funtion to delete, all i need to do is pass pass values of id's in checkboxes to this set accTeamToDeleteSet.

 Set  accTeamToDeleteSet = new Set
 List accTeamMemberToDeleteList = new List
 for (AccountTeamMember accTeam : [SELECT Id,AccountID,UserId from AccountTeamMember where Id in: accTeamToDeleteSet ])
 {
                    accTeamMemberToDeleteList.add(accTeam);
                }
delete accTeamMemberToDeleteList;

 

 

Hi all - 

 

   I am attempting to edit a visualforce page from the "Simple Quotes" application from appexchange. My question is much like one that was asked previously here: http://boards.developerforce.com/t5/General-Development/Error-Invalid-field-Contact-for-SObject-Opportunity/td-p/160764

 

I'm attempting to use the Opportunity object to store information about orders. The object already includes a lookup for Account, but it did not include a lookup for a Contact, the person who would have placed the order. 

 

I added a lookup field for Contact in the Opportunity object and want to reference it in a visual force page that generates a printable quote. Here is the code:

 

Account Information

Account name: {!Opportunity.Account.Name}  ---> Works as expected

 

Customer Information

Customer Name: {!Opportunity.Contact__c}   ---> This displays what looks to be an internal database ID instead of a name

Customer Name: {!Opportunity.Contact.Name}  ----> This returns the error: Error: Invalid field Contact for SObject Opportunity

 

I don't understand why Opportunity.Contact.Name does not work as expected. It seems both the Account and Contact are both lookup relationships to Opportunity. The advice in the other thread was to query the OpportunityContactRole object, but I've never heard of this object - is it hidden from the list of objects viewable from the web interface? I've added a custom lookup field to Contact, if I query this OpportunityContactRole, will it return the same result as what the user selects in the lookup field?

 

Thanks for your help!

Hi

 

using SalesForce;

 

SalesForce.SforceService service = newSforceService();

SaveResult [] saveResults = binding.create(accounts);

 

It gives error binding does not exist in current context.

 

Thanks

Hi All ,

 

I want to know that is there any limit for creating trigger on an object.

Means is there any limit to create before /After  insert / Update trigger on Account.

 

Or is it harmful to write 2 or more before insert trigger on an object.

 

Thanks in Advance.

Kindly advice.

 

Regards

Manish

 

 

 

 

 

Hi All,

 

This is similiar to my previous post but i think i was slightly wrong in what i needed to do, so does anyone have an idea how i can create a new button on a visual force page that acts like a new button on a standard object for a custom object? ie when i click the new button on my page i can then enter details in my new time sheet object just as though id created it from a new button from a standard page?

 

Cheers All

  • September 13, 2011
  • Like
  • 0

Hi All, I have a class and trigger that assign numbers to Opportunities depending on the business unit (Custom Field).  On a mass update (Dataloadre) I get duplicate values for this number, meaning two records will receive one number.  Below is my Trigger, thereafter my class.

 

Thanks in Advance.

 

trigger UpdateAutoNumber on Opportunity (before insert, before update) {
   
List <Opportunity> updates = new List <Opportunity>();   
if(Trigger.isInsert){
    Opportunity [] oppr =Trigger.new;
        AutoNumberHolder.display(oppr);
    }
   
   
   
if(Trigger.isUpdate){
    if (AutoNumberHolder.firstRun == true) {
     for (Opportunity oppr: Trigger.new){
        
          
                if(oppr.business_unit__c != Trigger.oldMap.get(oppr.Id).business_unit__c||
                   oppr.Product_Type__c != Trigger.oldMap.get(oppr.Id).Product_Type__c ){
                     updates.add(oppr);
                      
       
               }

         }
   

    }
    AutoNumberHolder.display(updates);
    AutoNumberHolder.firstRun = false;
  }
}

 

Class

 

public with sharing class AutoNumberHolder {
public static boolean firstRun = true;

public static void display(Opportunity [] oppr){

      integer ssaCounter = 0;
      integer ausCounter = 0;
      integer cisCounter = 0;
      integer indCounter = 0;
      integer bgtCounter = 0;
      integer betCounter = 0;
      integer delCounter = 0;
      integer bbaCounter = 0;
      integer baaCounter = 0;
      integer balCounter = 0;

for( Opportunity o: oppr){
          if(o.Business_Unit__c=='Bateman Engineering (SSA)')
                  ssaCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Engineering (AUS)')
                  ausCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Engineering (CIS)')
                  cisCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Engineering (IND)')
                  indCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Global Technology (BGT)')
                  bgtCounter += 1;

  
      
       else  if (o.Business_Unit__c=='Bateman Engineered Technologies (BET)')
                 betCounter = betCounter + 1;
                
         else if(o.Business_Unit__c=='Delkor Global (DEL)')
                  delCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Beijing Axis (BBA)')
                  bbaCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Africa (BAA)')
                  baaCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Litwin (BAL)')
                  balCounter += 1;
 }

AutoNumberHolder__c autoNum =[select id, Num1__c, Num2__c, Num3__c, Num4__c, Num5__c, Num6__c, Num7__c, Num8__c, Num9__c, Num10__c
                               from AutoNumberHolder__c LIMIT 1];

//assuming its an integer field - we are reserving numbers from the counter
//for the opportunities we have to number

integer ssaCtrStarts = autoNum.Num1__c.intValue() + 1;
integer ausCtrStarts = autoNum.Num2__c.intValue() + 1;
integer cisCtrStarts = autoNum.Num3__c.intValue() + 1;
integer indCtrStarts = autoNum.Num4__c.intValue()  + 1;
integer bgtCtrStarts = autoNum.Num5__c.intValue() + 1 ;

integer betCtrStarts = autoNum.Num6__c.intValue()  + 1;
integer delCtrStarts = autoNum.Num7__c.intValue() + 1;
integer bbaCtrStarts = autoNum.Num8__c.intValue()  + 1;
integer baaCtrStarts = autoNum.Num9__c.intValue()  + 1;
integer balCtrStarts = autoNum.Num10__c.intValue() + 1;

autoNum.Num1__c  +=  ssaCounter;
autoNum.Num2__c  += ausCounter;
autoNum.Num3__c  +=  cisCounter;
autoNum.Num4__c  += indCounter;
autoNum.Num5__c  +=  bgtCounter;

autoNum.Num6__c  += betCounter;
autoNum.Num7__c  +=  delCounter;
autoNum.Num8__c  += bbaCounter;
autoNum.Num9__c  += baaCounter;
autoNum.Num10__c  += balCounter;


update autoNum;

for( Opportunity o: oppr){
          if(o.Business_Unit__c=='Bateman Engineering (SSA)') {

               o.Enquiry_Number2__c = ssaCtrStarts.format();
               ssaCtrStarts +=1;
 }
         else if(o.Business_Unit__c=='Bateman Engineering (AUS)'){
                o.Enquiry_Number2__c = ausCtrStarts.format(); 
                ausCtrStarts += 1;
  }
         else  if(o.Business_Unit__c=='Bateman Engineering (CIS)'){
                o.Enquiry_Number2__c = cisCtrStarts.format(); 
                cisCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Engineering (IND)'){
                o.Enquiry_Number2__c = indCtrStarts.format(); 
                indCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Global Technology (BGT)'){

                o.Enquiry_Number2__c = bgtCtrStarts.format(); 
                bgtCtrStarts += 1;
 }
        
       
else  if(o.Business_Unit__c=='Bateman Engineered Technologies (BET)'){

                o.Enquiry_Number2__c = betCtrStarts.format(); 
                betCtrStarts += 1;
                system.debug('bmc Controller '+ betCtrStarts);
                system.debug('Enquiry Number '+ o.Enquiry_Number2__c);
 }
 

         else  if(o.Business_Unit__c=='Delkor Global (DEL)'){
                o.Enquiry_Number2__c = delCtrStarts.format(); 
                delCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Beijing Axis (BBA)'){
                o.Enquiry_Number2__c = bbaCtrStarts.format(); 
                bbaCtrStarts += 1;
  }
         else  if(o.Business_Unit__c=='Bateman Africa (BAA)'){
                o.Enquiry_Number2__c = bbaCtrStarts.format(); 
                baaCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Litwin (BAL)'){
                o.Enquiry_Number2__c = delCtrStarts.format(); 
                balCtrStarts += 1;
  }
 
}
 }
}

  • September 12, 2011
  • Like
  • 0

i am getting an error Foreign key external ID: 114.000000 not found for field Source_Account_ID__c in entity Account

 

when i am upserting the opportunites.. but Source_Account_ID__c is a text fiels in account and it is a primary key in account ...but in account it stored as 114 only.. 

 

 

Hello Guys,

 

I'm trying to use javascript remoting for my one of the requirement but facing a problem when i try to use the class variable inside the remoting method to set the value.

 

Code in controller i'm using is something like this:

global with sharing class MyJSController 
{
    public String strContactName { get; set; }
    
    @RemoteAction
    global static List<Account> getAccount(String accountName) 
    {
        accountName += '%';
        String str = 'select id, name, phone from Account where name like :accountName limit 1';
        List<Account> lstAccount = database.query(str);
        if(!lstAccount.isEmpty())
		{
			strContactName = [Select Id, LastName from Contact where AccountId =: lstAccount[0].Id limit 1].LastName;
            return lstAccount;
		}
        else
            return null;
    }   
}

JS code:

MyJSController.getAccount(buttonValue, function(result, event)
{
	if(event.status)
	{
		alert('{!strContactName}');
	}
}

 I just want to set a variable in the remote function which could be used in the Page.

Have anyone faced same issue or please suggest if there's any work around for this.

Thanks for you time.

Hi,

 

How can we get the Account Team members information of an opportunity in Apex.

 

your feedback is appreciated.

 

Regards

G.Surender

Is there a way in apex to know what record types the logged in user has access to on particular object?

Thanks.

I have created the following code. When I try to save I get  "Save Error: expecting a right parentheses, found 'true'"

 

} 

public class CloneProtocalArmActivities{

 

private Protocol_Arm__c contactClone = null;

private final Protocol_Arm__c contactBase = null;

 

public CloneProtocalArmActivities(ApexPages.StandardController controller) {

protocolarmBase = 

[SELECT Id, Protocol__c,

(SELECT Subject, WhoId, WhatId, ActivityDate, Status FROM Tasks)

FROMProtocol_Arm__c

WHERE Id = :ApexPages.currentPage().getParameters().get('Id')];

}

 

public PageReference cloneProtocolArm() {

protocolarmClone = protocolarmBase.clone(

false, // preserve ID

true// deep clone (all fields and relationships)

false, // preserve readonly timestamps

false  // preserve autonumbers

);

insert protocolarmClone;

        

if (!protocolarmBase.Tasks.isEmpty()) {

List<Task> tasks = protocolBase.Tasks.deepClone(

false, // preserve ID

false, // preserve readonly timestamps

false  // preserve autonumbers

);

for (Task t : tasks) { 

t.WhoId = protocolarmClone.Id; 

}

insert tasks;

}

}

PageReference newProtocolArmPage = new ApexPages.StandardController(protocolarmClone).view();

newProtocolArmPage.setRedirect(true);

       

return newProtocolArmPage;

}

 

Please help.

Hello,

 

My request is on the title. It seems to be simple, but I don't find a simple explanation to do that:

How do I pass data, from controller to javascript?

 

The situation is:

I have a controller which get some data from the database :

public with sharing class recup_donnees_test_Controller {
    
    Public LIST<Calendrier__c> GetCalendriers(){
            return Calendriers_Interne;
    }
    
    Public void SetCalendriers(LIST<Calendrier__c>Calendriers){
            Calendriers_Interne = Calendriers;
    }   

    Private LIST<Calendrier__c>Calendriers_Interne = new LIST<Calendrier__c>();

    Public recup_donnees_test_Controller (){
        
        Calendriers_Interne = [Select c.nom__c, c.id__c, c.Tache__c, c.SystemModstamp, c.Ressource__c, c.OwnerId, c.Name, c.LastModifiedDate, c.LastModifiedById, c.LastActivityDate, c.IsDeleted, c.Id, c.Heure_Fin__c, c.Heure_Debut__c, c.Date__c, c.CreatedDate, c.CreatedById, c.Categorie__c From Calendrier__c c WHERE c.Ressource__c = 'FRANCO-IDRISS Béatrice'];

    }
   

}

And then i have a Visual Force page, in which would like to get the data

 

Visual force page:

<apex:page Controller="recup_donnees_test_Controller" >

    <apex:pageBlock title="Calendrier">
    <apex:pageBlockTable value="{!Calendriers}" var="c">
        <apex:column headerValue="nom" value="{!c.nom__c}"/>
        <apex:column headerValue="Tâche" value="{!c.Tache__c}"/>
        <apex:column headerValue="Ressource" value="{!c.Ressource__c}"/>
        <apex:column headerValue="Date" value="{!c.Date__c}"/>
        <apex:column headerValue="Heure Début" value="{!c.Heure_Debut__c}"/>
        <apex:column headerValue="Heure Fin" value="{!c.Heure_Fin__c}"/>
 
    </apex:pageBlockTable>
</apex:pageBlock>



</apex:page>

 

if someone could help me?

Thank you

 

Emmanuel

  • November 10, 2011
  • Like
  • 0

is it possible to connect to different datasource objects in a single go? like i need to install the accounts contacts and opportunities in a single shot. from external datasource or 3 individula csv files....what is the best way to implement this?

When a user clicks "new" to make a new opportunity, they are faced with an entry form to enter in information. Is it possible to pre-populate one of these fields on this entry form using a trigger? 

  • October 14, 2011
  • Like
  • 0

Hi all,

 

I have a general question regarding the use of triggers. My problem is the following:

 

I have to schedule monthly an update over one checkbox field. The problem that I have is that I can't find an elegant solution to calculate the next month "date of update" because all the formulas I can build are based on TODAY() and, as you may have notice, that changes every day (what a surprise!).

 

My question is if whether I should use triggers or any other solution for this problem (workflows and update the needed field?)

 

If I need to create a trigger, do you have any clue on how to? Since the triggers trigger after or before an action happens, I don't have many ideas on how to model this...

 

Thank you all,

 

MGA

I would like to accomplish with an Appex Code OR Visual Force button that when I go to any Contact to create an activity (task -event- log a call) this new Activity "WILL BE RELATED TO" the Account they are associated to.
Can you help me to accomplish this? Salesforce Basic Support guide me to Developers website

Thank you,

 

Golan Jason Lewkowicz

212-431-3476 x202

Hi 


Is there a way to Create a Custom Formula field on the Account object that tells me if there is a future Activity on that account ?

i.e. if the Date (On Activity Object) Greater or Equal to Current day then set the field to True, if not then False ?

Thanks

Jim

 

hi all,

 

i am using the <apex:pageMessages /> tag in my vf page on top of the page below the <apex:form> tag. I am adding the below line code

 

ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error,'Name cannot be empty.'));

 

but, the error message is not populating or showing in the <apex:pageMessages /> tag... what i have to do to get this fixed and am i doing any thin wrong or is there anythin wrong with the syntax?? please help. thanks in advance

 

thanks

abivenkat

SFDC Learner 

Hi,  my trigger only fires for the first record in the batch when performing a dataloader insert.  Any ideas on how to get it to fire for all the records in each batch?  Dataloader is set to batchs of 200.  I don't want to reduce the batch to a count of 1, I need it to do bulk.  The trigger is designed to perform a vlookup (using the zip code on the lead as a reference) on a custom object (Postal Code Test)  and populate a custom field on the Lead object.  Each record on the Postal Code Test object contains a zip code and a corresponding internal territory.

 

here's the trigger:

 

trigger UpdateLeadAreaAssign on Lead (before Insert, before Update) {

    try {

        for(Lead x : Trigger.New) {

            //set to no area until it finds a territory matching the zip

            x.Lead_Territory_Trigger__c = 'NOAREA';

           

            //fetch territory from custom object using postal code from lead

            List<Postal_Code_Test__c> triggerLeadArea =

                [SELECT p.Lead_Territory__c

                FROM Postal_Code_Test__c p

                WHERE Zip_Code__c =: x.PostalCode

                LIMIT 1];

           

            //update lead territory field on lead

            x.Lead_Territory_Trigger__c = triggerLeadArea[0].Lead_Territory__c;       

        }

    } 

    catch (Exception e) {      

        System.Debug('ERROR: ' + e);

    }

}

Hi All,

 

This is similiar to my previous post but i think i was slightly wrong in what i needed to do, so does anyone have an idea how i can create a new button on a visual force page that acts like a new button on a standard object for a custom object? ie when i click the new button on my page i can then enter details in my new time sheet object just as though id created it from a new button from a standard page?

 

Cheers All

  • September 13, 2011
  • Like
  • 0