• Allen Manamel
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 19
    Replies
I am trying to display a state field in lightning component for a form and then calling the apex method to store the information, but it does not store the state value on the backend. I am not sure what is wrong with the code below.

Here is my lightning component code:

<aura:component  implements="forceCommunity:availableForAllPageTypes"  access="global" controller="StateController">
    <aura:attribute name="ContactInfo" type="Contact"  
                    default="{ 'sobjectType': 'Contact',
                             'addressLine1': '', 
                             'addressLine2': '', 
                             'city': '', 
                             'zip': '', 
                             'state': '',
                             'country': '',  
                             'citizenshipType': ''
                             }"/>

          <!---State-->
            <div class="form-element__control">
                <label class="form-element__label formlabel" for="state">State</label>
                <div class="form-element">
                    <div class="form-element__control">
                        
                        
                        <lightning:select   
                                          aura:id="fieldId"
                                          class="select" 
                                          name="state"
                                          label="State" 
                                          variant="label-hidden"
                                          required="true" 
                                          value="{!v.ContactInfo.Permanent_State_Province__c}"
                                          messageWhenValueMissing="Please Select a State">
                            
                            <option value="">Select a state</option>
                            <option value="AL">Alabama</option>
                            <option value="AK">Alaska</option>
                            <option value="AS">American Samoa</option>
                            <option value="AZ">Arizona</option>
                            <option value="AR">Arkansas</option>
                            <option value="CA">California</option>
                            <option value="CO">Colorado</option>
                            <option value="CT">Connecticut</option>
                            <option value="DE">Delaware</option>
                            <option value="DC">District of Columbia</option>
                            <option value="FL">Florida</option>
                            <option value="GA">Georgia</option>
                            <option value="HI">Hawaii</option>
                            <option value="ID">Idaho</option>
                            <option value="IL">Illinois</option>
                            <option value="IN">Indiana</option>
                            <option value="IA">Iowa</option>
                            <option value="KS">Kansas</option>
                            <option value="KY">Kentucky</option>
                            <option value="LA">Louisiana</option>
                            <option value="ME">Maine</option>
                            <option value="MD">Maryland</option>
                            <option value="MA">Massachusetts</option>
                            <option value="MI">Michigan</option>
                            <option value="MN">Minnesota</option>
                            <option value="MS">Mississippi</option>
                            <option value="MO">Missouri</option>
                            <option value="MT">Montana</option>
                            <option value="NE">Nebraska</option>
                            <option value="NV">Nevada</option>
                            <option value="NH">New Hampshire</option>
                            <option value="NJ">New Jersey</option>
                            <option value="NM">New Mexico</option>
                            <option value="NY">New York</option>
                            <option value="NC">North Carolina</option>
                            <option value="ND">North Dakota</option>
                            <option value="OH">Ohio</option>
                            <option value="OK">Oklahoma</option>
                            <option value="OR">Oregon</option>
                            <option value="PA">Pennsylvania</option>
                            <option value="PR">Puerto Rico</option>
                            <option value="RI">Rhode Island</option>
                            <option value="SC">South Carolina</option>
                            <option value="SD">South Dakota</option>
                            <option value="TN">Tennessee</option>
                            <option value="TX">Texas</option>
                            <option value="UT">Utah</option>
                            <option value="VT">Vermont</option>
                            <option value="VI">Virgin Islands</option>
                            <option value="VA">Virginia</option>
                            <option value="WA">Washington</option>
                            <option value="WV">West Virginia</option>
                            <option value="WI">Wisconsin</option>
                            <option value="WY">Wyoming</option>
                            <option value="AA">Armed Forces America</option>
                            
                        </lightning:select>
                    </div>
                </div>
            </div>

       <div>
            <lightning:button name="saveContinue" onclick="{!c.clickUpdate}"  > 
                Save and Continue 
            </lightning:button>
       </div>
    </aura:component>

**Controller Class:**
   
    ({
    clickUpdate : function(component, event, helper) {
        var allValid = component.find('fieldId').reduce(function (validSoFar, inputCmp) {
            inputCmp.showHelpMessageIfInvalid();
            return validSoFar && !inputCmp.get('v.validity').valueMissing;
        }, true);
        if(allValid){
            var isError = component.get("v.isError");
            if( isError ){
                component.set("v.isError", false);
            }
            helper.saveData(component,event,helper);
        }else{
            component.set("v.isError", true);
         }
       }

     })


**Helper Class:**

    ({
      saveData : function(component,event,helper) {
        var bttnClicked  =  event.getSource().get("v.name");
        var action = component.get("c.saveRecord");
        action.setParams({ 
            contactData : component.get("v.ContactInfo")
           
        });

      .........
      .........
      .........

    })


**Here is the apex class:**

    public without sharing class  StateController {

    @AuraEnabled
    public static void saveRecord(contact contactData){
        try{
            if(contactData!=null){
                update contactData;
            }
            
        }catch(Exception ex){
           system.debug('ex'+ex); 
        }
        
      }

    }
Hi,

 Background:

I have 3 objects: Contacts, Accounts, Campaign, Campaign Member that are involved in the scenario
Contact is the parent object, Accounts and Campaigns are child objects to contact(Related Lists)
There is a priority field on the account object.
There are many buckets on the campaign object, Red, Green, Blue which are mapped to the priority field of account.  So Let's see priority 1 means blue bucket, priority 2 means orange bucket, priority 3 means red bucket and so on.
 
What I want to do:

I want my trigger/batch job to loop over all contacts in Salesforce, for each contact, it finds the accounts associated with the contact(related list), checks the priority field on those accounts. The code should note down the highest priority from all those accounts associated with the specific contact, then add the contact as a campaign member in the corresponding campaign bucket. SO if the highest priority from all those accoounts come out to be 2, the contact should be added in orange campaign. 


Any idea how to achieve this? If somebody could provide a sample code to achieve this, it would be very helpful.

Thanks
I know that only the customer community license plus had an ability to approve/reject record and not the simple customer community license. I am trying to find out if Salesforce 19 release has changed this. If it provides the simple customer community license the ability to approve/reject records as well? Also my community users will be using Salesforce visualforce + tabs template i.e the standard salesforce UI(not sure if that matters vs using lightning templates like customer service e.t.c.)

Thanks
This is my use case. I have some community users and I want them to see the records only relevant to them.
I have an object 'Account' and a child object 'Point of Contact'. Account object has another child object 'sub-accounts'. Further sub-accounts has a 'Point of Contact' object too as well as another child object 'communication'. What I want is when a community user logs in, the system checks if the logged in user is listed as a user in "Point of Contact' object. If yes then he should be able to see that account/s as well as sub-accounts and the 'communication' records under it. Basically he should be able to see all level of records associated with that particular account. Second scenario, if the user is not listed in any of the 'Point of Contact' record related to a particular account, the system checks if he exists in any of the'Point of Contact' records that exists under 'Sub-accounts'. If yes, then the person should only be able to see that particular 'sub-account'(and not the parent account) as well as the communication records under that particular sub-account only.

Here is the screenshot of the hierarchy. 
User-added image

My question is is it possible to achieve this using a flow? such that the flow only does the condition checking and display records and does not really take any input from user at this point. or is there any other way to achieve this in Salesforce? Sharing rule does not seem to cater these complicated conditions.
I have a lookup field on my contact object named "ALO" and it is a restrictive lookup field as in it only accepts few values.I want to assign it the value stored in "account owner" field on the account object but here is the problem.
If the "account owner" value is the legitimate value for ALO lookup field i.e if the value exists as one of the options in ALO lookup field, only then it gets assigned otherwise if the value does not exist in the ALO field then it should set the field to null. However, I am confused how do I traverse the ALO lookup field to find out if the account owner value is an acceptable value for ALO lookup field?

Here is my code:

acc = [
                        
                        SELECT Id, OwnerId
                        FROM Account
                        WHERE Id =: contact.AccountId
                        ];
                        
                // I need help here        
                List<User> user= [SELECT ALO__c FROM contact where ALO =:acc.OwnerId];
                
                if (user.size() == 1) 
                
                  {
                
                       contact.ALO__c = acc.OwnerId;
                
                  }
                  
                else
                
                 {
                
                      contact.ALO__c= null;
                
                 }
I have the following code in my constructor method in apex class.

public Page4Controller() {

  User currentUser = [SELECT contactId  FROM User WHERE Id = :UserInfo.getUserId()];
        System.debug('Current user' + currentUser);
         //Fetch the current contact object
       if(String.isNotBlank(currentUser.ContactId)) {

            contact  = [
                SELECT  AccountId, firstName, lastName, MiddleName,  Nickname__c, Suffix, MailingStreet, MailingCity,
                MailingStateCode, Certify_Complete_and_Correct__c,  Certify_Download_Instructions_to_PreCan__c
                FROM Contact
                WHERE Id = :currentUser.ContactId
                LIMIT 1
            ];

            System.debug('contact information: ' + contact );

             //Fetch the current application object  
           application = [
                        
                        SELECT Id, Contact__c, Attend_College_after_High_School__c
                        FROM Application__c 
                        WHERE Contact__c =: currentUser.contactId
                        LIMIT 1];
            
                        
              }
}
And the following submit method

public pagereference submit() {
        
        if (
             contact.Certify_Complete_and_Correct__c == false ||
             contact.Certify_Download_Instructions_to_PreCan__c == false
                      
           ) 
        
              {
                 ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Please make sure all required fields are populated.');
                 ApexPages.addMessage(myMsg);
                 return null;
              }
        
       
                
        // ALO Code
        
         
         if(application.Attend_College_after_High_School__c == 'No')
         
            {
            
                acc = [
                        
                        SELECT Id, OwnerId
                        FROM Account
                        WHERE Id =: contact.AccountId
                        ];
                        
                
                contact.ALO__c = acc.OwnerId;
            
                        
              }
              
              
              
          else if(application.Attend_College_after_High_School__c == 'Yes')
          
              {
          
                  
                                 
                  ziptoLOD = [
                        
                        SELECT Id, Name, LOD__c
                        FROM Zip_3_to_LOD__c
                        WHERE Name =: contact.Extract_Zipcode__c
                        
                        ];
                        
                
                        
                  contact.ALO__c = ziptoLOD.LOD__c;
          
                      
             }
              
I don't know how to write test cases for the above conditions so that it covers both the if and else code.

Here is the test class I am working on

static testMethod void submit_Test() {

    Profile AdminProfile = [select id from profile where name='System Administrator']; 
    UserRole AdminRole = [SELECT id from UserRole where name = 'Admin'];


    User currentuser = new User();
      currentuser.firstname      ='James';
      currentuser.lastname      ='Dobb';
      currentuser.email         ='abcdefg@gmail.com';
      currentuser.username      ='abcdefg@gmail.com';
      currentuser.alias        ='jdobb';
      currentuser.TimeZoneSidKey  ='GMT';
      currentuser.LocaleSidKey    ='en_US';
      currentuser.emailencodingkey  ='UTF-8';
      currentuser.languagelocalekey  ='en_US';
      currentuser.ProfileId     = AdminProfile.Id;
      currentuser.userroleid     = AdminRole.Id;
      insert currentuser;
      
    
     Account acc= new Account();
     acc.OwnerId='005r0000001i9xA';
     acc.Name='Atlanta Area Tech School';
     acc.RecordTypeId='012r00000005DsA';
     
     
     Zip_3_to_LOD__c zip= new Zip_3_to_LOD__c();
     zip.Name = '480';
     zip.LOD__c = '005t0000001LDpi';
    
    Contact contact   = new Contact(); 
    contact.firstName = 'Alex';
    contact.lastName  = 'Cauller';
    contact.email     = 'alexcauller@gmail.com';
    contact.AccountId = acc.Id;
    
    
        
    system.runas(currentuser){
      insert acc;
      insert contact;
      insert zip;

      
    }
    
    
      
    Application__c app= new Application__c();
    app.Contact__c = contact.Id;
    app.Attend_College_after_High_School__c= 'No';
    
    
    system.runas(currentuser){
      
      insert app;
    }

    Profile pr = [select id from profile where name='......']; 
    User u = new User();
      u.firstname      ='James';
      u.lastname      ='Dobb';
      u.email         ='xyz@gmail.com';
      u.username      ='xyz@gmail.com';
      u.alias        ='jdobb';
      u.TimeZoneSidKey  ='GMT';
      u.LocaleSidKey    ='en_US';
      u.emailencodingkey  ='UTF-8';
      u.languagelocalekey  ='en_US';
      u.ProfileId     = pr.Id;
      u.contactId      =contact.id;
    insert u;

    system.runAs(u){
      System.Test.startTest();
      Page4Controller controllerClass = new Page4Controller();
      controllerClass.contact.Certify_Complete_and_Correct__c = false;
      controllerClass.contact.Certify_Download_Instructions_to_PreCan__c = false;
      controllerClass.submit();
      System.AssertEquals(controllerClass.contact.ALO__c,acc.OwnerId);
      controllerClass.application.Attend_College_after_High_School__c = 'Yes';
      controllerClass.submit();
      System.AssertEquals(controllerClass.contact.ALO__c,zip.LOD__c);
      controllerClass.previouspage();
      System.Test.stopTest();
      
           
    }
    
    
    When I run the test case, the test case fails and generates the following error on both the assert statements

System.AssertException: Assertion Failed: Expected: null, Actual: 005r0000001i9xAAAQ

    
    
    

    
  }

I have a dynamic picklist that I am displaying on the visualforce page.

Here is my visualforce code:
<apex:selectList value="{!SelectedNomination}" size="1" id="a">
   <apex:selectOptions value="{!contactlist}">
</apex:selectOptions> </apex:selectList>

Here is my apex code:
public List<SelectOption> contactlist
    {
                
        get
        
          {
          
          
            String state = application.Congressional_State_Territory__c.substring(0,2);
            Nominators = [Select Id, Name, Class_Year__c, Contact_Name__c, Nominator_Code__c, Nominator_Type__c from Nominator__c WHERE FirstTwoLetters__c =: state and Nominator_Type__c= 'Congressional - House' and Class_Year__c =: application.Class_Year__c and Status__c =:'Active' ORDER BY Name ASC ];
           
            
            contactlist = new List<SelectOption>();
             
            for(Nominator__c nom : Nominators)
            
            {
                
                contactlist.add(new SelectOption(nom.Id, nom.Name + ' ' + nom.Contact_Name__c));
                
            }
           
            return contactlist;
            
          }
          
        set {}
        
        
    } 



Here is my Test class:
List<Nominator__c> nomList = new List<Nominator__c>();
    
    Nominator__c nominator = new Nominator__c();
    
    nominator.Name= 'Florida District 2';
    nominator.Class_Year__c= '2023';
    nominator.Contact_Name__c= 'ABCD';
    nominator.Nominator_Code__c= 'GA02';
    nominator.Nominator_Type__c= 'Congressional - House';
    
    nomList.add(nominator);
    
    nominator = new Nominator__c();
    nominator.Name= 'Georgia District 9';
    nominator.Class_Year__c= '2023';
    nominator.Contact_Name__c= 'xyz';
    nominator.Nominator_Code__c= 'GA09';
    nominator.Nominator_Type__c= 'Congressional - House';
    
    nomList.add(nominator);
    
    system.runas(ownerUser){
      
     insert nomList;
    }


   system.runAs(u){
      usafa_PCQPage3Controller controllerClass = new usafa_PCQPage3Controller();
      List<SelectOption> options=controllerClass.contactlist;
      System.assertEquals(options.size(), 2);

}

}
 
When I run the test, I get the following error it fails and gives me the following error on this line

List<SelectOption> options=controllerClass.contactlist;

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

I have a dynamic picklist that displays the name of the nominator record + contact name field on that record. What I want is that when the user selects a value from the picklist it should fetch the id of the nominator record and save it in Congressional District field(nominator lookup field) on the application object in the saveandcontinue function
Note: Nominator is my custom object, contact is a field on nominator record

Here is my visualforce code

     <apex:selectList size="1" id="a">
         <apex:selectOptions value="{!contactlist}"></apex:selectOptions>
     </apex:selectList>

Here is my apex class

          public List<Nominator__c> Nominators = new List<Nominator__c>(); 
       
           public List<SelectOption> contactlist
    {
                
        get
        
          {
          
          
            String state = application.Congressional_State_Territory__c.substring(0,2);
            Nominators = [Select Id, Name, Class_Year__c, Contact_Name__c, Nominator_Code__c, Nominator_Type__c from Nominator__c        WHERE FirstTwoLetters__c =: state and Nominator_Type__c= 'Congressional - House' and Class_Year__c =: contact.HS_Grad_Year__c and Status__c =:'Active' ];
           
            
            contactlist = new List<SelectOption>();
             
            for(Nominator__c nom : Nominators)
            
            {
                
                contactlist.add(new SelectOption(nom.Id, nom.Name + ' ' + nom.Contact_Name__c));
                
            }
            
            return contactlist;
            
          }
          
        set
        
          {
        
        
            
        
          }
    } 

public pagereference saveAndContinue() {
// Need to write the code here
update application;
Pagereference Page = new Pagereference('/apex/Page_4');
Page.setRedirect(true);
return Page;
}


I know that we can save a user selected value on visualforce by using the value field on the selectlist but the part where I am stuck at is that how can I find the id of the nominator record chosen by the user and then save it in a field. Right now the select list only has the nominator name + contact data displayed on the picklist. Do I have to run a SOQL query again in the set function to grab the id or is there any other way? 
Hi All,

I have a piece of code in my apex controller in which I am trying to update the contact owner but it does update.

public pagereference submit() {

 if(contact.Region__c == '3')
       
           {
        
        
        // Fetch Assigned Users in Region 3 Territory
        
              List<UserTerritory2Association> UsersInRegion3 = new List<UserTerritory2Association>([SELECT Id, RoleInTerritory2, Territory2Id, UserId from UserTerritory2Association WHERE Territory2Id= '0MIr00000004CJp']);
              System.debug(UsersInRegion3);
              
              
              for(UserTerritory2Association a: UsersInRegion3)

                 {
   
                   
           
                   if(contact.UserCategory__c == 'FirstCategory' && a.RoleInTerritory2 == 'Regional Counselor A - K')
      
                        contact.OwnerId = a.UserId;
                   
                   else if (contact.UserCategory__c == 'SecondCategory' && a.RoleInTerritory2 == 'Regional Counselor L - Z')
      
                        contact.OwnerId = a.UserId;
           
   
                }

        
           }

Please let me know ASAP, how can I achieve this?
I have a field on contact object called 'Region' (Text formula field) whose end value would be in the range of 1-5. On the other hand, I have a territory model setup in my Salesforce instance. There are 5 territories with the Type Region that come on level 3 in model hierarchy. Here is my territory hierarchy screenshot.

User-added image

I have a field on contact object called 'Region' (Text formula field) whose end value would be in the range of 1-5. On the other hand, I have a territory model setup in my Salesforce instance. There are 5 territories with the Type Region that come on level 3 in model hierarchy. Here is my territory hierarchy Territory hierarchy
Here are the five region type territories

User-added image

What I want is that if the value in Region field is 1 on contact page, it should go to the Region 1 territory and check the assigned users in the region 1. Similarly for other regions. I am taking an example where Region value on contact object is 3. In that case, I want the code to go to Region 3, Traverse the assigned users in region 3 and check the "Role in Territory field" in assigned user.After it checks the "Role in Territory" which will either be Regional Counselor L-Z or Regional Counselor A-K (as shown in the screenshot). Then it compares the "last name" field on the contact object. If the user's last name starts with L-Z then in Region 3(in our example) in the assigned users, the one who has the Role "Regional Counselor L-Z" should be assigned to the "Owner" lookup field on the contact object. if last name starts with A-K then the user with the role "Regional Counselor A-K" should be populated in the "Owner" field on contact object.
Screenshot attached for Region 3. 
User-added image


 
I have a field on contact object called 'Region' (Text formual field) whose end value would be in the range of 1-5. On the other hand, I have a territory model setup in my Salesforce instance. There are 5 territories with the Type Region that come on level 3 in model hierarchy. Here is my territory hierarchy
User-added image

Here are the five region type territories

User-added image

What I want is that if the value in Region field is 1 on contact page, it should go to the Region 1 territory and check the assigned users in the region 1. Similarly for other regions. I am taking an example where Region value on contact object is 3. In that case, I want the code to go to Region 3, Traverse the assigned users in region 3 and check the "Role in Territory field" in assigned user. And then there is some other processing. Right now I don't even know how to reach to that point.
Screenshot attached for Region 3.
User-added image
Hi,

I have an account field(lookup field to account) and a user lookup field called ALO  on contact object . What I want  to do is to find out the account name field value on contact object, traverse that account , fetch the owner id and then assign that to the ALO field on the contact object.

This is what I have written in my apex controller but I am getting some syntax error maybe because of the API names that I am using. Can anybody help please?

public Account acc {get; set;}

     acc = [
                        
                        SELECT Id, OwnerId
                        FROM Account
                        WHERE Id =: contact.Account
                        ];
                        
               contact.ALO= acc.OwnerId;

where 'contact' is the current contact instance.
I have a lookup field to Account object on "Application" object with some filter criteria. The fieldname is Congressional_District__c on Application object.

Here is my visualforce code:
<apex:inputField required="true" id="CongressionalRepresentative" value="{!CongressionalDistrict.Congressional_District__c}" />

where CongressionalDistrict is the method name in the apex class.

Here is the method in my apex class:
 public Application__c getCongressionalDistrict()
    {
        return [select Congressional_District__c from Application__c limit 1];
        
    }

This returns me a text field(instead of a lookup) which constantly displays the first value in the lookup field(instead of multiple values in lookup so that user can select a value). Attached is the screenshot:

User-added image

Also if I remove limit 1 at the end and do
return [select Congressional_District__c from Application__c];

it gives me error.

Any help would be appreciated. 
Hi,

I have a form and some custom input fields that work fine when I run as an internal user but when I run it as a community user, the fields disappear. I checked the field level security and those are accessible to community user. Can anybody let me know where else I can check the settings?

Thanks
 
I have a dynamic picklist that displays the name of the nominator record + contact name field on that record. What I want is that when the user selects a value from the picklist it should fetch the id of the nominator record and save it in Congressional District field(nominator lookup field) on the application object in the saveandcontinue function
Note: Nominator is my custom object, contact is a field on nominator record

Here is my visualforce code

     <apex:selectList size="1" id="a">
         <apex:selectOptions value="{!contactlist}"></apex:selectOptions>
     </apex:selectList>

Here is my apex class

          public List<Nominator__c> Nominators = new List<Nominator__c>(); 
       
           public List<SelectOption> contactlist
    {
                
        get
        
          {
          
          
            String state = application.Congressional_State_Territory__c.substring(0,2);
            Nominators = [Select Id, Name, Class_Year__c, Contact_Name__c, Nominator_Code__c, Nominator_Type__c from Nominator__c        WHERE FirstTwoLetters__c =: state and Nominator_Type__c= 'Congressional - House' and Class_Year__c =: contact.HS_Grad_Year__c and Status__c =:'Active' ];
           
            
            contactlist = new List<SelectOption>();
             
            for(Nominator__c nom : Nominators)
            
            {
                
                contactlist.add(new SelectOption(nom.Id, nom.Name + ' ' + nom.Contact_Name__c));
                
            }
            
            return contactlist;
            
          }
          
        set
        
          {
        
        
            
        
          }
    } 

public pagereference saveAndContinue() {
// Need to write the code here
update application;
Pagereference Page = new Pagereference('/apex/Page_4');
Page.setRedirect(true);
return Page;
}


I know that we can save a user selected value on visualforce by using the value field on the selectlist but the part where I am stuck at is that how can I find the id of the nominator record chosen by the user and then save it in a field. Right now the select list only has the nominator name + contact data displayed on the picklist. Do I have to run a SOQL query again in the set function to grab the id or is there any other way? 
I have a field on contact object called 'Region' (Text formula field) whose end value would be in the range of 1-5. On the other hand, I have a territory model setup in my Salesforce instance. There are 5 territories with the Type Region that come on level 3 in model hierarchy. Here is my territory hierarchy screenshot.

User-added image

I have a field on contact object called 'Region' (Text formula field) whose end value would be in the range of 1-5. On the other hand, I have a territory model setup in my Salesforce instance. There are 5 territories with the Type Region that come on level 3 in model hierarchy. Here is my territory hierarchy Territory hierarchy
Here are the five region type territories

User-added image

What I want is that if the value in Region field is 1 on contact page, it should go to the Region 1 territory and check the assigned users in the region 1. Similarly for other regions. I am taking an example where Region value on contact object is 3. In that case, I want the code to go to Region 3, Traverse the assigned users in region 3 and check the "Role in Territory field" in assigned user.After it checks the "Role in Territory" which will either be Regional Counselor L-Z or Regional Counselor A-K (as shown in the screenshot). Then it compares the "last name" field on the contact object. If the user's last name starts with L-Z then in Region 3(in our example) in the assigned users, the one who has the Role "Regional Counselor L-Z" should be assigned to the "Owner" lookup field on the contact object. if last name starts with A-K then the user with the role "Regional Counselor A-K" should be populated in the "Owner" field on contact object.
Screenshot attached for Region 3. 
User-added image


 
Hi,

I have an account field(lookup field to account) and a user lookup field called ALO  on contact object . What I want  to do is to find out the account name field value on contact object, traverse that account , fetch the owner id and then assign that to the ALO field on the contact object.

This is what I have written in my apex controller but I am getting some syntax error maybe because of the API names that I am using. Can anybody help please?

public Account acc {get; set;}

     acc = [
                        
                        SELECT Id, OwnerId
                        FROM Account
                        WHERE Id =: contact.Account
                        ];
                        
               contact.ALO= acc.OwnerId;

where 'contact' is the current contact instance.
I have a lookup field to Account object on "Application" object with some filter criteria. The fieldname is Congressional_District__c on Application object.

Here is my visualforce code:
<apex:inputField required="true" id="CongressionalRepresentative" value="{!CongressionalDistrict.Congressional_District__c}" />

where CongressionalDistrict is the method name in the apex class.

Here is the method in my apex class:
 public Application__c getCongressionalDistrict()
    {
        return [select Congressional_District__c from Application__c limit 1];
        
    }

This returns me a text field(instead of a lookup) which constantly displays the first value in the lookup field(instead of multiple values in lookup so that user can select a value). Attached is the screenshot:

User-added image

Also if I remove limit 1 at the end and do
return [select Congressional_District__c from Application__c];

it gives me error.

Any help would be appreciated. 
Hi,

I have a form and some custom input fields that work fine when I run as an internal user but when I run it as a community user, the fields disappear. I checked the field level security and those are accessible to community user. Can anybody let me know where else I can check the settings?

Thanks
 
I am building a 'List<SelectOption>' and populating it with 'new SelectOption's, then using it in an apex:selectCheckboxes construct to output a set of checkboxes on a VF page. When Salesforce generates the checkboxes, I see the <input> and <label> tags as I expect. However, some of the labels in a list are very long, and I want to disable the functionality of clicking the labels to change the status of the associated checkbox. It can lead to inadvertent setting or unsetting of the checkbox values. How can I disable the clickability? In straight HTML coding, I can set the onclick handler to return false, which prevents it from altering the checkbox value, but I have not been able to figure out how to implement that in this case, since I don't seem to have access to parameters of the <label> command.

Example coding from the controller:
dynamicSEPOptions = new List<SelectOption>();
dynamicSEPOptions.Add(new SelectOption('First', '</label>Short normal label<label>'));
dynamicSEPOptions.Add(new SelectOption('Second', '</label>This is a very long label, which should point out that it could lead to inadvertent setting of the checkbox value<label>'));
dynamicSEPOptions.Add(new SelectOption('Third', '</label>This is an even longer label, wrapping over several lines, which, regardless of the content of the text, should not be clickable to set the checkbox value because it doesn\'t conform to current web experience standards and can result in incorrect checkbox values<label>'));

Example code from the VF page:
<apex:selectCheckboxes value="<field name>" layout="pageDirection" >
     <apex:selectOptions value="{!dynamicSEPOptions}" />
</apex:selectCheckboxes>

Output checkbox list on the page:
Output example of checkboxes
Hi All,

We are using a visualforce page and a field 'Taxtype'(Input picklist field contains 10 values) in that page.We are displaying that field from fieldset.Now we got the below requirement.

Based on the country that user selects while registration,we need to display only the related values dynamically in 'Taxtype' field,not all 10 values when he/she redirected to that particular page.

How can we achieve this requirement through apex and visualforce?

Thanks in advance.
Hi All. How to query for accounts in child territories? I can't seem to find any documentation for this 

Currently I'm able to query for the accounts in the current logged-in user's territrry only, but not from the sibling territories.

Following is my code...
 
public class TrackingPartners{

    public List<orders__c> orders {get; set;}
    public TrackingPartners() {   
    }
    
    
    public list<orders__c> getstart() {

    Map<Id,UserTerritory> UserTerritoryCurrentUserMap = new  Map<Id,UserTerritory>([Select u.UserId, u.TerritoryId, u.IsActive, u.Id  From UserTerritory u Where u.isActive=true and u.userId =: UserInfo.getUserId()]);

    
    
    set<Id> TerritoryIdSet = new set<Id>();
	
    for(UserTerritory ut:UserTerritoryCurrentUserMap.values())
    {
          TerritoryIdSet.add(ut.TerritoryId);
    }    

      list<Group> map_group = [Select Id, RelatedId from Group where (Type='Territory' OR Type='TerritoryAndSubordinates') AND RelatedId IN : TerritoryIdSet];


    List<SYSTEMS__c> lst_PartnersAcc = [SELECT CUST_NUM__c,Account__c
                                                 FROM SYSTEMS__c WHERE Account__c IN                                                  
                                                 (Select  AccountId from AccountShare where ( UserOrGroupId IN : map_group OR  UserOrGroupId =:UserInfo.getUserId()) AND RowCause IN ('Territory', 'TerritoryManual', 'TerritoryRule'))
                                                 ];

                                                 
    Set<String>tempList = new Set<String>();

    for(SYSTEMS__c s : lst_PartnersAcc) {
        tempList.add(s.CUST_NUM__c);

        
    }
    
    List<orders__c> orders =[SELECT Orders__c,id FROM orders__c   
                                 WHERE  Bill_to__c IN: tempList OR
                                        Payer__c IN: tempList OR 
                                        Ship_To__c IN: tempList OR
                                        Sold_to__c IN: tempList
                                     ]; 
                                    

     return orders;                                
  }                                
  
}

How to query accounts from the child territory? Any reference would be great. Thanks in advance! 
  • February 20, 2015
  • Like
  • 0
I have created the below Visualforce page which gets the data for the Opportunity object from the user. The Opportunity object has a field - Account name which contains a lookup to the Account object. But when I refer it through the Inputfield using {!opportunity.account.name}, it is displayed as a text box and not as a lookup field to Account object. Can someone please tell me how to modify the code? 

<apex:page controller="opptycontroller" tabStyle="Opportunity">
<apex:sectionHeader title="New Customer Opportunity" subtitle="Step 2 of 3"/>
    <apex:form >
        <apex:pageBlock title="Opportunity information" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!step3}" value="Next"/>
            </apex:pageBlockButtons>
        <apex:pageBlockSection title="Opportunity products">
            <apex:inputField id="opportunityType" value="{!opportunity.type}"/>
            <apex:inputField id="opportunityLeadSource" value="{!opportunity.LeadSource}"/>
            <apex:inputField id="opportunityProbability" value="{!opportunity.Probability}"/>
           <apex:inputField id="opportunityAccountName" value="{!opportunity.account.name}"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>