• AndrewNerney
  • NEWBIE
  • 65 Points
  • Member since 2014
  • Solutions Engineer
  • zPaper


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 20
    Replies
I have created a field on the Contact object Active_Community_User__c, to be checked when we set up a Community user, and unchecked when we deactivate the Community user.

I need to update this field on existing Community users. Logically that would be best done through the Execute Anonymous window, but the code I have written isn't producing results.

The code appears to execute without error, but nothing changes.

Help?
 
List<User> userList = [ select user.Id, user.Contact.Active_Community_User__c from user where user.IsActive = True and (user.Profile.Name ='zConnect Community User' or user.Profile.Name = 'zConnect Community User Login')]; 

for(User us : userList) { 
    us.Contact.Active_Community_User__c = True; 
} 

update userList;

 
Hey everybody. I'm new to using GIT and VSCode and am trying to work through the various Trailhead modules and other exercies.

I'm working through Org Development Model > Develop and Test Changes Locally and have created a DEV org, installed VSCode and GIT on my Windows machine, created and initalized a remote GitHub repository, and downloaded that repository to my local machine. I have also created a handful of custom objects and fields in the DEV org, and have successfully downloaded them to the local machine repository via the Command Terminal in VSCode.

However, I am unable to see these changed items in Source Control in VSCode, because VSCode is reading from the wrong directory.
Commit the Changes to the Source Control Repository

Ella commits her changes to the repo, then creates a pull request to inform Juan that her changes are ready to review.
  1. In VS Code, select the  Source Control icon.
  2. Enter a commit comment, then click the  Commit icon.
  3. Click Yes to add and commit the files.
  4. From the VS Code command palette, select Git: Push To.
  5. Select the origin repository
 
When I select the Source Control icon in VSCodee, what I expect to see is VSCode reading from the local repository at
C:\Users\User\Documents\VSCode\platform-app-builder\platform-app-builder

and showing a handful of changes.

What I see instead is VSCode reading from the Windows AppData/Local directory and showing thousands of changes (because this directory contains tons of application files)

What did I miss?

User-added image

In a Community I am using a Lightning component with lightning:recordViewForm and lightning:outputField to display fields from existing Cases.

Two of the fields are lookups, AccountId and ContactId. They are rendered as hyperlinks, and if the user clicks either link they are taken to an Account or Contact page. We don't want this - we only want the Account Name and Contact Name to be displayed (with no hyperlink).

Is it possible to set some variant or property on the lightning:outputField for AccountID and ContactID to achieve this? Or do I need to go another route?

Thanks for any help!

<aura:component implements="force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">   
    <lightning:card title="Case Detail" iconName="standard:case">
        <p class="slds-p-horizontal_small">
        <lightning:recordViewForm recordId="{!v.recordId}" objectApiName="Case">
              <!--<div class="slds-grid full forcePageBlockSectionRow">-->
              <div class="slds-grid slds-gutters">
                  <!--<div class="slds-col slds-size_1-of-2">-->
                  <div class="slds-col">
                    <!--<lightning:outputField fieldName="AccountId" variant="label-hidden"/>-->
                    <lightning:outputField fieldName="AccountId"/>
                    <lightning:outputField fieldName="ContactId"/>                    
                </div>
                               
                <div class="slds-col">
                <!--<div class="slds-col slds-size_1-of-2">-->
                    <lightning:outputField fieldName="Organization_Id__c"/>
                    <lightning:outputField fieldName="HowManyUsersImpacted__c"/>
                </div>
              </div>

            <div class="slds-theme_default">
                <lightning:outputField fieldName="Client_Ref__c"/>  
                <lightning:outputField fieldName="Workaround_In_Place__c"/>	
                <lightning:outputField fieldName="Description"/>
                <lightning:outputField fieldName="Error_Message__c"/>
                <lightning:outputField fieldName="Steps_to_Reproduce__c"/>
            </div>
        </lightning:recordViewForm>
        </p>
    </lightning:card>
    
</aura:component>

 
I'm stuck on a simple Trailhead module Get Started with Enterprise Territory Management.

The Challenge is fairly straightforward.
  • Turn on the Enterprise Territory Management feature and accept the default access level: View and edit accounts assigned to the territory
  • Create a territory type called Managed Accounts with a priority of 100 and this description: Actively managed accounts
  • Create a territory model called Current Calendar Year with this description: Territory model for the current calendar year
  • In the Current Calendar Year territory model, create a territory called US East Coast with territory type Managed Accounts and this description: Managed accounts on US East Coast


The feedback is:
Challenge Not yet complete... here's what's wrong: 
Did you enter the correct description for the territory?


As best I can tell I have the setup correct. Any ideas?

User-added image

User-added image

 

On the Trailhead challenge for Create and Run a Bulk Macro I am getting the error "The instruction isn't available" when running the macro. The errant instruction is "Select Status Change Action."

I've reviewed all of the suggestions from this article and am still getting the error. What could be causing this?

https://help.salesforce.com/articleView?id=000220033&type=1

I'm running the test under a System Administrator account, which has the full access to the Case object and full FLS access to the Status field.

The Change Status action is on the page layout, and the Status field is on the action's layout: 

User-added image

I can execute the action from the Case Feed, and the Status field is available:

User-added image

Any ideas as to why the macro won't run?


 
I'm pursing the Trailhead project Build a Community with Knowledge and Chat. Actually, I've already passed it and gotten the badge, but the LiveAgent isn't working as expected in the Community.

To my knowledge I followed all instructions to the letter, but when I preview the community, I see no "Chat with an Expert" button. I added the Snap-ins Chat to the sidebar as the instructions state, and I logged into the console and set the LiveAgent status to "Online." But when I preview the community, no chat button shows.

Any ideas? I am certain that I followed all steps. But I probably missed something, since the button doesn't show in the community.
Hi everyone,

We are working on a beta release for an AppExchange product, and I am installing the managed package in various dev orgs. I have noticed that if I select "Install for Admins Only" during setup, all elements are installed with access given only to System Administrator users, but if I later reinstall the same package and select "Install for All Users," nothing changes. If I install the package in a new org and select "Install for All Users," then all users are given access to the package. Is this how things are supposed to be?

Example:
I install the managed package and select "Install for Admins Only"
The field security for the custom field faxType on the Case object is set to Visible for the System Administrator profile only
I then reinstall the managed package and select "Install for All Users."
Salesforce gives the message "Installing and granting access for all users," but the field security on faxType remains Visible for System Administrators only.
If I want to grant all users access to the package, I have to first uninstall it.

I did a quick test by creating a small managed package with a single field, and I got the same results.

Is this right? If not, then what could be the reason for this behavior?
I have the following setup:
Physician__c Grandparent object
Account Child object
Assessment__c Grandchild object

I am trying to update values on Assessment__c whenever certain fields on Physician__c are updated, but I am getting an Apex CPU time limit exceeded when doing a bulk load.

From some research I see that I will need to use some combination of lists and/or maps to create a list of records to update. I can pull the list of Physicians but am getting stuck when attempting to identify the appropriate Assessment__c records.

In this code, Apex doesn't seem to like the IN :physWithAssessments.Id part.
List<Physician__c> physWithAssessments = [select Id, Fax__c, Fax_Number_Verified__c, (select Id from Accounts__r) From Physician__c where Id IN :Trigger.newMap.keySet()];

List<Assessment__c> currAssessments = [select Id, Member_Account__r.Primary_Care_Physician__r.Id, z_PCPFaxExists__c, z_PCPFaxNumVerified__c From Assessment__c  Where Member_Account__r.Primary_Care_Physician__r.Id IN :physWithAssessments.Id];
What might be a better approach here?

This is how the code currently looks (without any attempts at using lists or maps). It works fine unless you are doing a bulk load.

Warning: ugly code ahead!
trigger zUpdateFaxInfo_Physician on Physician__c (after update) {

    List<Assessment__c> assessmentsToUpdate = new List<Assessment__c>();

    for (Assessment__c assmnt: [select Id, Member_Account__r.Primary_Care_Physician__r.Id, Member_Account__r.Primary_Care_Physician__r.Fax__c, 
        Member_Account__r.Primary_Care_Physician__r.Fax_Number_Verified__c FROM Assessment__c WHERE Member_Account__r.Primary_Care_Physician__r.Id IN :Trigger.newMap.keySet()]){

        Physician__c oldphys = Trigger.oldMap.get(assmnt.Member_Account__r.Primary_Care_Physician__r.Id);
  
    //only update the database if the Physician's Fax__c or Fax_Number_Verified__c fields have been updated
        if (oldphys.Fax__c != assmnt.Member_Account__r.Primary_Care_Physician__r.Fax__c || 
            oldphys.Fax_Number_Verified__c != assmnt.Member_Account__r.Primary_Care_Physician__r.Fax_Number_Verified__c){ 

            System.debug('@FaxUpdate code fired on Physician__C record ' + assmnt.Member_Account__r.Primary_Care_Physician__r.Id);
    
    //set dummy field z_PCPFaxExists__c to TRUE if the physician has a fax number, or false otherwise
                If(assmnt.Member_Account__r.Primary_Care_Physician__r.Fax__c != null){
                    assmnt.z_PCPFaxExists__c = True;    
                }
                    Else
                {
                    assmnt.z_PCPFaxExists__c = False;      
                }
    
    //set dummy field z_PCPFaxNumVerified__c to TRUE if the physician's fax number has been verified, or false otherwise
                If(assmnt.Member_Account__r.Primary_Care_Physician__r.Fax_Number_Verified__c == True){
                    assmnt.z_PCPFaxNumVerified__c = True;    
                }
                    Else
                {
                    assmnt.z_PCPFaxNumVerified__c = False;      
                }    
    
               assessmentsToUpdate.add(assmnt);
           
        }

     }

//update database
       update assessmentsToUpdate; //update database
}
  1.  
We have a custom object Physician__c with a lookup to this object on the Account object. The relationship is 1:many, the field name on the Account object is Primary_Care_Physician__c, and the field is not required.

I'm working on a trigger on the Account object and need to reference some fields on the parent Physician__c object. I figure that the best approach is to use the getSobject() feature.

I'm attempting to reference the field Fax__c on the parent object but am getting the error Invalid relationship Physician__c for Account: Trigger.zUpdateFaxInfo_Account.

 As best I can tell my syntax is correct, but obviously something is not right. Help?
trigger zUpdateFaxInfo_Account on Account (after update) {

    for (Account acct : Trigger.new) {
    
        Account oldacct = Trigger.oldMap.get(acct.ID);
 
        String FaxNumber = (String) acct.getSobject('Physician__c').get('Fax__c');
 
//rest of code will go into here

        
        }

}



Hi all, 

Here's what I hope is a simple/easy question. I've been away from coding for a good while and only have a bit of APEX experience, so it's fair to say I'm a code noob at the moment.

I need to do a cross-object field update from a custom object Physician__c to a Person Account. The relationship is 1:many. I have a dummy field on the Person Account which should be updated whenever the field Fax__c on the object Physician__c is changed.

I'm getting the following error when updating a Physician__c record. Help?

Apex trigger zUpdateMember caused an unexpected exception, contact your administrator: zUpdateMember: execution of AfterUpdate caused by: System.TypeException: Invalid id value for this SObject type: a18Z0000001Gx7XIAS: Trigger.zUpdateMember: line 10, column 1


Here is the code:

trigger zUpdateMember on Physician__c (after insert, after update) {

//LATER - MUST ADD CODE TO ONLY FIRE WHEN FAX FIELD HAS BEEN UPDATED

    List<Account> accountsToUpdate = new List<Account>();
 
   // For each patient account associated with the physician, update the dummy field z_PCPFaxExists__c
    for (Physician__c p : Trigger.new){
   
        Account tempAccount = new Account(Id = p.ID);
       // Only update accounts that we need to update
            If(p.Fax__c != null){
                tempAccount.z_PCPFaxExists__c = true;
            }
            Else
            { 
                tempAccount.z_PCPFaxExists__c = false;
            }
            accountsToUpdate.add(tempAccount);
//        }                         
    }
    // update Accounts
    update accountsToUpdate;

}
This is the Knowledge Base article that I used as a guide:

Apex Trigger cross-object field update

https://help.salesforce.com/HTViewSolution?id=000002636&language=en_US (https://help.salesforce.com/HTViewSolution?id=000002636&language=en_US)

Knowledge Article Number: 000002636


Description
In order to update a field on object B based on critera of object A we must use apex. (When not using roll up summary or formula)


Resolution
// Example: Update Contact based on update/insert of CampaignMember

trigger UpdateField on CampaignMember (after update, after insert) {
  
    List<Contact> contactsToUpdate = new List<Contact>();

   // For each CampaignMember, update contact
    for (CampaignMember o : Trigger.new){
        Contact tempContact = new Contact(Id = o.contactid);
   // Only update contacts that we need to update
        If(tempContact.Do_not_email__c != o.Do_not_email__c){
           tempContact.Do_not_email__c = o.Do_not_email__c;
           contactsToUpdate.add(tempContact);

        }

    }
    // update Contacts
    update contactsToUpdate;

}





I have created a field on the Contact object Active_Community_User__c, to be checked when we set up a Community user, and unchecked when we deactivate the Community user.

I need to update this field on existing Community users. Logically that would be best done through the Execute Anonymous window, but the code I have written isn't producing results.

The code appears to execute without error, but nothing changes.

Help?
 
List<User> userList = [ select user.Id, user.Contact.Active_Community_User__c from user where user.IsActive = True and (user.Profile.Name ='zConnect Community User' or user.Profile.Name = 'zConnect Community User Login')]; 

for(User us : userList) { 
    us.Contact.Active_Community_User__c = True; 
} 

update userList;

 
I remember years back, when I give "View All Data" or "Modify All data" system permission at the profile level, it will automatically give all FLS.  but when I check today, it seems only give object level permission, we still need to manually check all FLS for all objects. is there a easier way to grant all FLS to profile?

In a Community I am using a Lightning component with lightning:recordViewForm and lightning:outputField to display fields from existing Cases.

Two of the fields are lookups, AccountId and ContactId. They are rendered as hyperlinks, and if the user clicks either link they are taken to an Account or Contact page. We don't want this - we only want the Account Name and Contact Name to be displayed (with no hyperlink).

Is it possible to set some variant or property on the lightning:outputField for AccountID and ContactID to achieve this? Or do I need to go another route?

Thanks for any help!

<aura:component implements="force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">   
    <lightning:card title="Case Detail" iconName="standard:case">
        <p class="slds-p-horizontal_small">
        <lightning:recordViewForm recordId="{!v.recordId}" objectApiName="Case">
              <!--<div class="slds-grid full forcePageBlockSectionRow">-->
              <div class="slds-grid slds-gutters">
                  <!--<div class="slds-col slds-size_1-of-2">-->
                  <div class="slds-col">
                    <!--<lightning:outputField fieldName="AccountId" variant="label-hidden"/>-->
                    <lightning:outputField fieldName="AccountId"/>
                    <lightning:outputField fieldName="ContactId"/>                    
                </div>
                               
                <div class="slds-col">
                <!--<div class="slds-col slds-size_1-of-2">-->
                    <lightning:outputField fieldName="Organization_Id__c"/>
                    <lightning:outputField fieldName="HowManyUsersImpacted__c"/>
                </div>
              </div>

            <div class="slds-theme_default">
                <lightning:outputField fieldName="Client_Ref__c"/>  
                <lightning:outputField fieldName="Workaround_In_Place__c"/>	
                <lightning:outputField fieldName="Description"/>
                <lightning:outputField fieldName="Error_Message__c"/>
                <lightning:outputField fieldName="Steps_to_Reproduce__c"/>
            </div>
        </lightning:recordViewForm>
        </p>
    </lightning:card>
    
</aura:component>

 
I'm stuck on a simple Trailhead module Get Started with Enterprise Territory Management.

The Challenge is fairly straightforward.
  • Turn on the Enterprise Territory Management feature and accept the default access level: View and edit accounts assigned to the territory
  • Create a territory type called Managed Accounts with a priority of 100 and this description: Actively managed accounts
  • Create a territory model called Current Calendar Year with this description: Territory model for the current calendar year
  • In the Current Calendar Year territory model, create a territory called US East Coast with territory type Managed Accounts and this description: Managed accounts on US East Coast


The feedback is:
Challenge Not yet complete... here's what's wrong: 
Did you enter the correct description for the territory?


As best I can tell I have the setup correct. Any ideas?

User-added image

User-added image

 

Hi All

The 'Define Forecast Rollups and Default Date Ranges' unit is giving me the following error when I have done exactly what is asked in the challenge, hence an apparent error in the Trailhead checking process:
Challenge Not yet complete... here's what's wrong:
Couldn’t find default forecast display period 'Monthly', starting on '1 month ago', display '4 months'. Please double check the instructions.

Is there some apparently irrelevant setting I need that is not specified? It's not as if this is a complex unit!

Thanks
Keith
 
Hi everyone,

We are working on a beta release for an AppExchange product, and I am installing the managed package in various dev orgs. I have noticed that if I select "Install for Admins Only" during setup, all elements are installed with access given only to System Administrator users, but if I later reinstall the same package and select "Install for All Users," nothing changes. If I install the package in a new org and select "Install for All Users," then all users are given access to the package. Is this how things are supposed to be?

Example:
I install the managed package and select "Install for Admins Only"
The field security for the custom field faxType on the Case object is set to Visible for the System Administrator profile only
I then reinstall the managed package and select "Install for All Users."
Salesforce gives the message "Installing and granting access for all users," but the field security on faxType remains Visible for System Administrators only.
If I want to grant all users access to the package, I have to first uninstall it.

I did a quick test by creating a small managed package with a single field, and I got the same results.

Is this right? If not, then what could be the reason for this behavior?
I have the following setup:
Physician__c Grandparent object
Account Child object
Assessment__c Grandchild object

I am trying to update values on Assessment__c whenever certain fields on Physician__c are updated, but I am getting an Apex CPU time limit exceeded when doing a bulk load.

From some research I see that I will need to use some combination of lists and/or maps to create a list of records to update. I can pull the list of Physicians but am getting stuck when attempting to identify the appropriate Assessment__c records.

In this code, Apex doesn't seem to like the IN :physWithAssessments.Id part.
List<Physician__c> physWithAssessments = [select Id, Fax__c, Fax_Number_Verified__c, (select Id from Accounts__r) From Physician__c where Id IN :Trigger.newMap.keySet()];

List<Assessment__c> currAssessments = [select Id, Member_Account__r.Primary_Care_Physician__r.Id, z_PCPFaxExists__c, z_PCPFaxNumVerified__c From Assessment__c  Where Member_Account__r.Primary_Care_Physician__r.Id IN :physWithAssessments.Id];
What might be a better approach here?

This is how the code currently looks (without any attempts at using lists or maps). It works fine unless you are doing a bulk load.

Warning: ugly code ahead!
trigger zUpdateFaxInfo_Physician on Physician__c (after update) {

    List<Assessment__c> assessmentsToUpdate = new List<Assessment__c>();

    for (Assessment__c assmnt: [select Id, Member_Account__r.Primary_Care_Physician__r.Id, Member_Account__r.Primary_Care_Physician__r.Fax__c, 
        Member_Account__r.Primary_Care_Physician__r.Fax_Number_Verified__c FROM Assessment__c WHERE Member_Account__r.Primary_Care_Physician__r.Id IN :Trigger.newMap.keySet()]){

        Physician__c oldphys = Trigger.oldMap.get(assmnt.Member_Account__r.Primary_Care_Physician__r.Id);
  
    //only update the database if the Physician's Fax__c or Fax_Number_Verified__c fields have been updated
        if (oldphys.Fax__c != assmnt.Member_Account__r.Primary_Care_Physician__r.Fax__c || 
            oldphys.Fax_Number_Verified__c != assmnt.Member_Account__r.Primary_Care_Physician__r.Fax_Number_Verified__c){ 

            System.debug('@FaxUpdate code fired on Physician__C record ' + assmnt.Member_Account__r.Primary_Care_Physician__r.Id);
    
    //set dummy field z_PCPFaxExists__c to TRUE if the physician has a fax number, or false otherwise
                If(assmnt.Member_Account__r.Primary_Care_Physician__r.Fax__c != null){
                    assmnt.z_PCPFaxExists__c = True;    
                }
                    Else
                {
                    assmnt.z_PCPFaxExists__c = False;      
                }
    
    //set dummy field z_PCPFaxNumVerified__c to TRUE if the physician's fax number has been verified, or false otherwise
                If(assmnt.Member_Account__r.Primary_Care_Physician__r.Fax_Number_Verified__c == True){
                    assmnt.z_PCPFaxNumVerified__c = True;    
                }
                    Else
                {
                    assmnt.z_PCPFaxNumVerified__c = False;      
                }    
    
               assessmentsToUpdate.add(assmnt);
           
        }

     }

//update database
       update assessmentsToUpdate; //update database
}
  1.  
We have a custom object Physician__c with a lookup to this object on the Account object. The relationship is 1:many, the field name on the Account object is Primary_Care_Physician__c, and the field is not required.

I'm working on a trigger on the Account object and need to reference some fields on the parent Physician__c object. I figure that the best approach is to use the getSobject() feature.

I'm attempting to reference the field Fax__c on the parent object but am getting the error Invalid relationship Physician__c for Account: Trigger.zUpdateFaxInfo_Account.

 As best I can tell my syntax is correct, but obviously something is not right. Help?
trigger zUpdateFaxInfo_Account on Account (after update) {

    for (Account acct : Trigger.new) {
    
        Account oldacct = Trigger.oldMap.get(acct.ID);
 
        String FaxNumber = (String) acct.getSobject('Physician__c').get('Fax__c');
 
//rest of code will go into here

        
        }

}



Hi all, 

Here's what I hope is a simple/easy question. I've been away from coding for a good while and only have a bit of APEX experience, so it's fair to say I'm a code noob at the moment.

I need to do a cross-object field update from a custom object Physician__c to a Person Account. The relationship is 1:many. I have a dummy field on the Person Account which should be updated whenever the field Fax__c on the object Physician__c is changed.

I'm getting the following error when updating a Physician__c record. Help?

Apex trigger zUpdateMember caused an unexpected exception, contact your administrator: zUpdateMember: execution of AfterUpdate caused by: System.TypeException: Invalid id value for this SObject type: a18Z0000001Gx7XIAS: Trigger.zUpdateMember: line 10, column 1


Here is the code:

trigger zUpdateMember on Physician__c (after insert, after update) {

//LATER - MUST ADD CODE TO ONLY FIRE WHEN FAX FIELD HAS BEEN UPDATED

    List<Account> accountsToUpdate = new List<Account>();
 
   // For each patient account associated with the physician, update the dummy field z_PCPFaxExists__c
    for (Physician__c p : Trigger.new){
   
        Account tempAccount = new Account(Id = p.ID);
       // Only update accounts that we need to update
            If(p.Fax__c != null){
                tempAccount.z_PCPFaxExists__c = true;
            }
            Else
            { 
                tempAccount.z_PCPFaxExists__c = false;
            }
            accountsToUpdate.add(tempAccount);
//        }                         
    }
    // update Accounts
    update accountsToUpdate;

}
This is the Knowledge Base article that I used as a guide:

Apex Trigger cross-object field update

https://help.salesforce.com/HTViewSolution?id=000002636&language=en_US (https://help.salesforce.com/HTViewSolution?id=000002636&language=en_US)

Knowledge Article Number: 000002636


Description
In order to update a field on object B based on critera of object A we must use apex. (When not using roll up summary or formula)


Resolution
// Example: Update Contact based on update/insert of CampaignMember

trigger UpdateField on CampaignMember (after update, after insert) {
  
    List<Contact> contactsToUpdate = new List<Contact>();

   // For each CampaignMember, update contact
    for (CampaignMember o : Trigger.new){
        Contact tempContact = new Contact(Id = o.contactid);
   // Only update contacts that we need to update
        If(tempContact.Do_not_email__c != o.Do_not_email__c){
           tempContact.Do_not_email__c = o.Do_not_email__c;
           contactsToUpdate.add(tempContact);

        }

    }
    // update Contacts
    update contactsToUpdate;

}