• reymagdaong
  • NEWBIE
  • 35 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 0
    Questions
  • 25
    Replies
Hi,
 
 Wrote a below trigger after insert and after update for some reasons its not firing please suggest me what might be the issue. 
 
trigger territory_lookup on Lead (After Insert, After Update) 
{
  Try 
  {
 set<id> gid = new set<id>();
 Set<String> gzip = new Set<String>();
 Set<String> gstate = new Set<String>();
 Set<String> gcountry = new Set<String>();
 
 Integer intzip;

 lead ld = [select id,postalcode,state,country from lead where id = :Trigger.newMap.keySet() limit 1];

 intzip=Integer.valueof(ld.postalcode);

  system.debug(intzip);
 
 String ldstate;
 String ldcountry;
 
  ldstate = ld.state;
  ldcountry = ld.country;
  Territory_Lookup__c tl = [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where Zip_Start__c <= :intzip and Zip_End__c >= :intzip and
                                 State__c in :gstate and Country__c in :gcountry limit 1];
                                

  list<lead> led = [select id,postalcode,state,country from lead where id = :Trigger.newMap.keySet() limit 1];
 
  for(lead uld : led)
  {
   uld.Territory_Area__c = tl.Area__c;
   uld.Territory_Region__c = tl.Region__c;
   uld.Territory_Theater__c = tl.Theater__c;
   }

  update led;

 }  
     
  catch(Exception ex){
  system.debug(ex);

  
  }    

}

Thanks
Sudhir
Hi Guys,

I want to create a tree structure which is present in custom object.I am having custom object called "employee information" and in that object, I am having lookup field "Parent Employee" with the same object records for mapping "parent employee" to another employee.

After saving the records I want to display that employee information in tree structure by using visualforce page.User-added image
Please help me to achieve this.
i know if i write in my coode this:
SELECT Name, department, phone, gender__c, birthdate FROM contact WHERE AccountID='00136000002JfHw' ORDER BY birthdate desc

this show i want to see but i want to show others contacts asociated with others accounts to.

my code VP
 
<apex:page applyHTMLTag="true" applyBodyTag="false" showHeader="false" renderas="pdf" standardController="Account" extensions="ContactsListController" >
<style type="text/css">
<apex:stylesheet value="{!URLFOR($Resource.style)}"/>
   </style>
<html>
   <body>
        <div style="float: left; ">
         <apex:image alt="cargill" title="cargill"
              url="{!URLFOR($Resource.cargill)}"/>    
     </div> 
        <div style="float: right; ">
    <br/>     
   <apex:outputText value="Caracas,{0,date, dd/MM/yyy}">
       <apex:param value="{!NOW()}" />
                   </apex:outputText><br/>
          {! IF($User.isActive, $User.FirstName & ' ' & $User.LastName,  'inactive') } <br/>
           {! Account.Name }
      
    </div> 
      	<div style="clear:both;"> </div><br/><br/><br/>
           <apex:pageBlock >
               
    <apex:pageBlockTable value="{!Account.contacts}" var="contact">
       
	    <apex:column value="{!contact.Name}"/>
        <apex:column value="{!contact.Department}"/>
        <apex:column value="{!contact.Phone}"/>
        <apex:column value="{!contact.Gender__c}"/> 
        <apex:column value="{!contact.Birthdate}"/>    
        <apex:column >
        <apex:facet name="header">Age</apex:facet>
                        {!year(today())-year(contact.birthdate)- 1}
        </apex:column> 
   
    </apex:pageBlockTable>
          </apex:pageBlock>
     
     
   </body>
</html>       
</apex:page>

and my controller
 
public class ContactsListController 
{   
   	private final Account acct;
    	public ContactsListController(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
    }       
	public List<Contact> getContacts() 
	{
		List<Contact> results = [SELECT Name, department,phone,gender__c, birthdate FROM contact WHERE account.ID='00136000002JfHw'

                                     ORDER BY birthdate desc]  ;
		return results;
       
	}
}

i think, i need to change anything in my controller but i dont know.
 
There are times where I create new custum fields directly in Production. But the Sandbox won't have those fields. Now I want to sync Sandbox with production as I'm testing few things on sandbox. Is there a quick way to do it?

Current situation -
Production = A + B + C
Sandbox = A + B + D

After sync -
Production = A + B + C
Sandbox = A + B + C + D

Please help

 
Hi All ,

I have a visualforce page in production org which has started to give time limit exceed error at some times in last two days.Salesforce Server Status page doesnt display any performance issues at given times.It is not a page with a complex functionality or large amount of data.Other pages in the same org works find at the time page is giving the error .Any Idea on this
  • February 18, 2016
  • Like
  • 1
I have an app to show iteratively the IDs by selecting a checkBox. I need to merge the selected accounts, how can I do that?
This is the Controller:
 
public class MyAccountListCntrlr {
// PROPERTIES
public List<AccountWrapperCls> acctList {get;set;}
public Set<String> selAccountNames {get;set;}
public Boolean hasSelAcct {get;set;}
public static List<Account> accts;

//  MESSAGE
public static  Boolean showMessage {get;set;}
public static String message {get;set;}


 // CONSTRUCTOR
 public MyAccountListCntrlr(){
      acctList = new List<AccountWrapperCls>();
      selAccountNames = new Set<String>();
     showMessage = false;
      for(Account a : [SELECT AccountNumber, name, id, phone, fax, website, type, industry, description, NumberOfEmployees, BillingCity, AnnualRevenue from account
      LIMIT 10]){
           acctList.add(new AccountWrapperCls(a));
      }
 }

 // METHODS
 public void displaySelectedAccountNumbers(){
      //selAccountNames.clear();
      hasSelAcct = false;
      for(AccountWrapperCls cWrapper : acctList){
           if(cWrapper.isSelected){
                hasSelAcct = true;
                selAccountNames.add(cWrapper.cAccount.id);
                //showMessage = true;
                //message = 'The following error has ocurred: \n' + cWrapper.cAccount.id;
                //accts.add(cWrapper.cAccount);
           }
           if(selAccountNames.size() > 1)
            {
                for(Integer i = 1; i < selAccountNames.size(); i++)
                {
                    showMessage = true;
                    message = ' The selected accounts are: \n' + selAccountNames;
                } 
            }
      }
   }
I am also use a Wrapper Class such the following:
public class AccountWrapperCls {
 public Boolean isSelected {get;set;}
 public Account cAccount {get;set;}     

 public AccountWrapperCls(Account cAccount){
      this.cAccount = cAccount; } }//End AccountWrapperCls

And this is the VisualForce Page:
 
<apex:page controller="MyAccountListCntrlr" tabStyle="Account">

<!-- ACCOUNT LIST -->
     <apex:pageBlockTable value="{!acctList}" var="acctWrapper">
        <apex:column >
           <apex:inputCheckbox value="{!acctWrapper.isSelected}"/>
        </apex:column> 
        <apex:column value="{!acctWrapper.cAccount.AccountNumber}"/>
        <apex:column value="{!acctWrapper.cAccount.Name}"/>
         <apex:column value="{!acctWrapper.cAccount.website}"/>
     </apex:pageBlockTable>

      <!--//Message-->
         <apex:outputText rendered="{!showMessage}" id="tests">
             <script>
             alert("{!JSENCODE(message)}")
             </script>
         </apex:outputText>

     <!-- SELECTED ACCOUNT INFO -->
     <apex:pageBlockSection >
        <apex:outputPanel layout="block" rendered="{!hasSelAcct}">
           <apex:outputText value="Below are the selected account:"/>
           <br/>
           <apex:outputText value="{!selAccountNames}"/>
         </apex:outputPanel>
         <apex:outputPanel layout="block" rendered="{!NOT(hasSelAcct)}">
            <br/>
            <apex:outputText value="No account selected."/>
         </apex:outputPanel>
     </apex:pageBlockSection>
  </apex:pageBlock>

How can I merge the selected accounts? Any ideas or code? Thanks in advance.
 
Hi Folks,

I am not able to edit my apex class because in the backend some Schedule Apex classes are running but am not able to find exact Schedule Apex Class.

How can we find out the scheduler class name and that belongs to which class.

Is there any logic behind that,to get to know exactly(I had tried with queries but not able to find any solution)

Please guide me...

Thanks in Advance....
Hi ,
what kind of situation we are using extension controller? when we will use give me with best example.


Regards,
Viswa
How do i need to fetch record name from record id in salesforce


Thanks
Laxman
Map<String,Map<String,List<Map<String,List<Map<String,String>>>>>> tempvar = new Map<String,Map<String,List<Map<String,List<Map<String,String>>>>>>();
is there any alterntive or best practise? i am well aware about wrapper classes.
I am creating a pre-chat page for live agent, I have copied the same code from Pre-Chat Form Code Sample mentioned in live agent developer guide, just replaced the button Ids.
I placed one chat button (ID : 573g00000008Ofd) on a VF page for testing with this pre-chat page. On clicking that, the pre-chat form opens. But when the form is submitted it always redirect to this button's custom chat page, regardless of which button I select from the drop down.

<select name="liveagent.prechat.buttons">
<option value="573g00000008Ofd">Chat Button 1 </option>
<option value="573g00000008OfY">Chat Button 2 </option>
</select>

Please let me know if I am missing something or some other code needs to be incorporated to get redirected to respective custom chat pages of the buttons.
 
I am preparing for salesforce developer I certification and ran into a question:
 
A Developer wants to create a custom object to track Customer Invoices.
How should Invoices and Accounts be related to relate that all invoices are visible to everyone with access to the Account?
Of course it’s going to be a master detail relationship
There are two options:
The Invoice should have master detail relationship to the Account
 The Account should have master detail relationship to the Invoice.I want to know what is the difference between the two. They both look similar.
Can someone please help
Hai friends! 
While displaying map values on a pageblock table every time i m getting below error...can any body help me how to understand this and fix?
Error:
Incorrect parameter type for subscript. Expected java.lang.Class, received DateTime
Error is in expression '{!eventmap[key]}' in component <apex:pageBlock> in page 
My code is:
<apex:page controller="DisplaySectionsController11">
<apex:form >
<apex:repeat value="{!eventmap}" var="key">
<apex:pageBlock title="{!key}">
<apex:pageblocktable value="{!eventmap[key]}" var="a">
<apex:column value="{!a.Subject}"/>
<apex:column value="{!a.Startdatetime}"/>
<apex:column value="{!a.Enddatetime}"/>
</apex:pageBlock>
</apex:repeat>
<apex:commandButton value="ss" action="{!Query}"/>
</apex:form>
</apex:page>
Hi Experts,

Please find below Class & Page. It is not showing output values.

Apex Class:

public class RetrieveClassesTriggersInWrapper{

   public List<ApexClass> classNames{set;get;}
   public List<ApexTrigger> triggerNames{set;get;}
   public List<ApexClass> testClassNames{set;get;}
   public List<Apexpage> pageNames{set;get;}
   public List<MyWrapper> wrapper {get; set;}


   public void RetrieveClassesTriggersInWrapper()
   {
     classNames=[SELECT id, name from ApexClass where not(Name like '%test%') ORDER BY Name ASC];
     triggerNames=[SELECT id, name from ApexTrigger ORDER BY Name ASC];
     testClassNames=[SELECT id, name from ApexClass where (Name like '%test%') ORDER BY Name ASC];
     pageNames=[SELECT id, name from Apexpage ORDER BY Name ASC];
     
     wrapper = new List<MyWrapper>() ;
 
     for(Integer i=0 ; i < 10 ; i++)
     wrapper.add(new MyWrapper(classNames[i], triggerNames[i], testClassNames[i], pageNames[i])) ;

   }

   public class MyWrapper
   {
     public ApexClass Classes {get; set;}
     public ApexTrigger Triger {get; set;}
     public ApexClass testClass {get; set;}
     public Apexpage vfPage {get; set;}

       
     public MyWrapper(ApexClass cls, ApexTrigger tri, ApexClass testCls, Apexpage page)
     {
        Classes = cls ;
        Triger = tri ;
        testClass = testCls;
        vfPage = page;
     }
  }
}


VF Page:

<apex:page controller="RetrieveClassesTriggersInWrapper">
  <apex:pageBlock >
   <apex:pageblockSection >
     <apex:pageBlockTable value="{!wrapper}" var="wrap">
       <apex:column headerValue="Classes" value="{!wrap.Classes.Name}"/>
       <apex:column headerValue="Triggers" value="{!wrap.Triger.Name}"/>
       <apex:column headerValue="TestClasses" value="{!wrap.testClass.Name}"/>
       <apex:column headerValue="Visualforce Pages" value="{!wrap.vfPage.Name}"/>
     </apex:pageblockTable>
   </apex:pageblockSection>
  </apex:pageBlock>
</apex:page>

Out put:  Output not showing any values.

Output


Please anyone help me.

Thanks,
Manu
Hi,
 
 Wrote a below trigger after insert and after update for some reasons its not firing please suggest me what might be the issue. 
 
trigger territory_lookup on Lead (After Insert, After Update) 
{
  Try 
  {
 set<id> gid = new set<id>();
 Set<String> gzip = new Set<String>();
 Set<String> gstate = new Set<String>();
 Set<String> gcountry = new Set<String>();
 
 Integer intzip;

 lead ld = [select id,postalcode,state,country from lead where id = :Trigger.newMap.keySet() limit 1];

 intzip=Integer.valueof(ld.postalcode);

  system.debug(intzip);
 
 String ldstate;
 String ldcountry;
 
  ldstate = ld.state;
  ldcountry = ld.country;
  Territory_Lookup__c tl = [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where Zip_Start__c <= :intzip and Zip_End__c >= :intzip and
                                 State__c in :gstate and Country__c in :gcountry limit 1];
                                

  list<lead> led = [select id,postalcode,state,country from lead where id = :Trigger.newMap.keySet() limit 1];
 
  for(lead uld : led)
  {
   uld.Territory_Area__c = tl.Area__c;
   uld.Territory_Region__c = tl.Region__c;
   uld.Territory_Theater__c = tl.Theater__c;
   }

  update led;

 }  
     
  catch(Exception ex){
  system.debug(ex);

  
  }    

}

Thanks
Sudhir
Hi All ,

I have a visualforce page in production org which has started to give time limit exceed error at some times in last two days.Salesforce Server Status page doesnt display any performance issues at given times.It is not a page with a complex functionality or large amount of data.Other pages in the same org works find at the time page is giving the error .Any Idea on this
  • February 18, 2016
  • Like
  • 1
I want to know whether a currency field value is in USD using DescribeFieldResult?

Something like Schema.DescribeFieldResult.getType() == Schema.DisplayType.CURRENCY
{
    //this value is in USD ?
}

is there any way to do this ?

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.