• Melissa Bunch
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 6
    Replies
Hello!

I would like to display the actual Account Hierarchy within a Lightning Component on the Lightning Record Page for my Accounts.

I was able to find code to add a Lightning Component that links to the hierarchy, but I want to actually display the hierarchy instead.

Does anyone know how to do this? Below is a screenshot of the code I found and how it looks. Maybe I can edit the existing code to display the hierarchy?

COMPONENT
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title">
            <button aria-controls="expando-unique-id" aria-expanded="true" class="slds-button slds-section__title-action">
                <lightning:icon iconName="utility:switch" alternativeText="" size="x-small" />
                <span class="slds-truncate" title="Section Title"> &nbsp;Account Hierarchy Link</span>
            </button>
        </h3>
        <div aria-hidden="false" class="slds-section__content" id="expando-unique-id">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="{!c.navigateToAccountHierarchy}">View Account Hierarchy</a>
        </div>
    </div>
</aura:component>

CONTROLLER

({
    navigateToAccountHierarchy: function(cmp, event, helper) {
        var acctId = cmp.get('v.recordId');
        var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
            componentDef: "sfa:hierarchyFullView",
            componentAttributes: {
                recordId: acctId,
                sObjectName: "Account"
            }
        });
        evt.fire();
    }
})

RESULT
User-added image
I don't write code, so bear with me.

I have a portion of an Apex Class that pulls a list of records based on record type for Cases. However, I need to add a criteria here that then looks at the received records and only includes the records where a certain field is filled in.

Current code:


List<RecordType> residentialRecordTypes = [SELECT Id
                                           FROM RecordType
                                           WHERE (DeveloperName = 'Residential' OR DeveloperName = 'Carpet' OR DeveloperName = 'Manufacturing_Distribution' OR DeveloperName = 'Residential_Service_Claims' OR DeveloperName = 'Mannington_Rubber')
                                           AND SobjectType = 'Case'
                                           AND Id in: casesByRecordTypeId.keySet()
                                           LIMIT 1];


So I essentially need to add something like:

AND Case.Division__c LIKE 'Residential'

Any idea how I would do this?

Thank you!

Melissa
Hello,

I have a visualforce page that displays currency and it shows a $ and decimal just fine, but it isn't displaying commas.

The code is below (I did not write it - I am not a dev). Is there an easy input I can add to have a comma display?

The fields populate with existing values and area also editable, if that matters.

<apex:page standardController="Account" extensions="New_Business_Plan_Process_Controller" action="{!mangerCheckAction}"  showheader="false" sidebar="false" standardStylesheets="false">
   <!-- <script src="jquery.js" type="text/javascript"></script>-->

    <apex:form id="formId">

    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <apex:stylesheet value="{!URLFOR($Resource.ManningtonSlds, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />

      <style>
      body{background:url("/resource/ManningtonSlds/assets/images/body-noise.jpg") repeat 0 0;}
      .slds-container--large{ margin: 0 auto;padding:0 1rem}

      .main-sec{border-radius:5px;border:2px solid #009ddc;box-shadow:0 0 6px rgba(0,0,0,0.6);margin:3rem 0 1rem;background:#fff}
      .sldsform-details{padding:1.5rem 1rem 1rem;}
      .sldsform-sec .slds-form-element__row{padding-bottom:1rem;display:flex; display:-webkit-flex; align-items: center; -webkit-align-items: center;}
      .sldsform-sec .sldsleft-col{min-width:300px;padding-right:1.5rem;text-align:right}
      .sldsform-sec .sldsright-col{width:400px;position:relative}
      .slds-btn-row{display:flex; display:-webkit-flex; justify-content: center;margin-top:0.5rem}
      .Mannington .heading{background:#009ddc;color:#fff;padding:0.25rem 0 0.3rem;text-align:center;font-weight:700 }
      .currencyinput{    position: absolute;left: 5px;top: 0;line-height:32px;}
      .common-error-message .message table{color:#cc0000}
      /*resposive css start */
       @media (max-width: 767px) {
       .main-sec{margin-top:1rem}
       .sldsform-sec .sldsleft-col{min-width:230px}

       }

       @media (max-width: 479px) {

       .sldsform-sec .slds-form-element__row{padding-bottom:0;flex-wrap: wrap;-webkit-flex-wrap: wrap;}
       .sldsform-sec .sldsleft-col{width:100%;text-align:left;padding:0 0 5px 0}
       .sldsform-sec .sldsright-col{width:100%;padding-bottom:0.8rem}
       .sldsform-sec .first-form-element__row {flex-wrap: inherit;-webkit-flex-wrap: inherit;padding-bottom:1rem}
       .sldsform-sec .first-form-element__row .sldsleft-col{min-width:80px;padding:0 10px 0 0;width:auto}
       .sldsform-sec .first-form-element__row .sldsright-col{padding-bottom:0}
       }
      </style>
    </head>
    <div class="common-error-message">
     <apex:pageMessages id="showmsg"></apex:pageMessages>
     </div>
    <div class="Mannington">
    <div class="slds-container--large">
    <div class="main-sec">
    <h1 class="slds-text-heading--medium heading">Business Plan</h1>
    <div class="slds-scope sldsform-details">

           <apex:outputPanel id="divShow0" rendered="{!managerFlag}" >
                <div class="sldsform-sec">
                    <div class="slds-form-element__row first-form-element__row">
                        <div class="sldsleft-col">
                            Account:
                        </div>
                        <div class="sldsright-col">
                            {!Acc.Name}
                        </div>
                    </div>
                   <div class="slds-form-element__row">
                       <div class="sldsleft-col">
                            Choose Product Category:
                        </div>
                        <div class="sldsright-col">
                         <div class="slds-select_container">
                            <apex:selectList styleClass="slds-select" id="PickList" value="{!ValuePickList}" size="1" required="true">
                                <apex:selectOptions value="{!PicklistValues}"/>
                                <apex:actionSupport event="onchange" reRender="formId" action="{!showDiv}"/>
                            </apex:selectList>
                            </div>
                        </div>
                    </div>
                </div>

  </apex:outputPanel>
    <apex:outputPanel id="divShow" >
        <apex:outputPanel id="NetPotential" rendered="{!flag}">
            <div class="sldsform-sec">
               <div class="slds-form-element__row">
                    <div class="sldsleft-col">
                        {!ValuePickList} Annual Purchase Potential:
                    </div>
                   <div class="sldsright-col">
                     <span class="currencyinput">$</span>
                    <apex:inputtext styleclass="slds-input " html-type="number"  value="{!netPotential}">

                    </apex:inputtext>

                    </div>
                </div>

                <div class="slds-form-element__row">
                    <div class="sldsleft-col">
                        {!ValuePickList} Annual Commitment:
                    </div>
                    <div class="sldsright-col">
                     <span class="currencyinput">$</span>
                    <apex:inputtext styleclass="slds-input" html-type="number" value="{!commitment}"/>
                    </div>
                </div>

              <div class="slds-form-element__row">
                    <div class="sldsleft-col">
                        {!ValuePickList} Annual Revenue:
                    </div>
                    <div class="sldsright-col">
                     <span class="currencyinput">$</span>
                        <apex:Outputtext styleclass="slds-input" html-readonly="true"  value="{!AnnualRevenue}"/>

                    </div>
                </div>

               <!--  <div class="slds-form-element__row">
                    <div class="sldsleft-col">
                        Plan Name:
                    </div>
                    <div class="sldsright-col">
                        <apex:inputtext styleclass="slds-input"   value="{!planName}" />
                    </div>
                </div> -->
                <div class="slds-form-element__row">
                    <div class="sldsleft-col">
                        Plan:
                    </div>
                    <div class="sldsright-col">
                        <apex:inputtextarea styleclass="slds-input"   value="{!plan}"/>
                    </div>
                </div>



            </div>
            <div class="slds-btn-row">
                <apex:commandButton styleClass="slds-button slds-button--brand" value="Save Business Plan" action="{!updatePlan}" oncomplete="closeWindowFunc();" rerender="formId"/>
                <apex:commandButton styleClass="slds-button slds-button--destructive" value="Cancel"  onclick="closeButton();" rerender="formId"/>
                </div>


        </apex:outputPanel>
    </apex:outputPanel>
    </div>
    </div>
   </div>
   </div>
   <script>
    function closeWindowFunc()
    {
        var flag="{!closeFlag}";
        //alert(flag);
        if(flag=='true')
        {
            var aid="{!acc.id}"
            var url='/'+aid;
            if((typeof sforce != 'undefined') && (sforce != null))
            {
                // Salesforce1 navigation
                sforce.one.navigateToSObject(aid);
            } else
            {
                window.close();
            }
        }

    }

    function closeButton()
    {
        var aid="{!acc.id}"
        var url='/'+aid;
        //alert(url);
        /*if ((typeof sforce != 'undefined') && sforce && (!!sforce.one))
         {
                alert(url);             // Salesforce1 navigation
                     sforce.one.navigateToURL(navigateURL);
         }*/
         if((typeof sforce != 'undefined') && (sforce != null))
        {
            sforce.one.navigateToSObject(aid);
        }
         else
         {
          window.close();
         }
    }








    </script>
    </apex:form>

</apex:page>

Hello!

I'm not a developer, so I really don't know anything about code.
I managed to write an Apex Trigger and Test Class, but my Test Class only has 40% code coverage and is preventing me from deploying to Production.

I've read multiple articles and posts, but can't seem to interpret other solutions and apply them to my own.

Can anyone give any advice on how to increase this?
Thank you!
 

Here is my Trigger & Class:

TRIGGER:
trigger Unlock_Order_Pending_Approval on Order (after update) {
//Get records to unlock
List<order> orderList = [SELECT Id From Order WHERE CreatedDate = TODAY AND Unlock_Order__c != Null ];
//Check locked records
List<order> orderLockList = new List<Order>();
for(Order c :orderList){
if(Approval.isLocked(c.id)){
orderLockList.add(c);
}
}
//Unlock record
if(!orderLockList.isEmpty()){
//Unlock records
List<Approval.UnlockResult> ulrList = Approval.unlock(orderLockList, false);

// Iterate through each returned result
for(Approval.UnlockResult ulr : ulrList) {
if (ulr.isSuccess()) {
//Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked account with ID: ' + ulr.getId());
}
else {
//Operation failed, so get all errors
for(Database.Error err : ulr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Order fields that affected this error: ' + err.getFields());
}
}
}
}
}


TEST CLASS
@isTest 
public class Test_Unlock_Order_Pending_Approval { 
   @isTest
    public static void Test_Unlock_Order_Pending_Approval() {
//Create Account, create Order with that Account, submit into approval process, change field on order, unlock record

        Account Acc=new Account();
        Acc.Name='test';
        Acc.Type='A&D Firm';
        Acc.Industry='A&D Firm';
        insert Acc;
        
        Opportunity Opp=new Opportunity();
        Opp.Name='new opp';
        Opp.CloseDate=System.today();
        Opp.StageName='Verified Project';
        Opp.AccountId='Acc.id';
        insert Opp;
        delete Opp;

     Order OrdObj=new Order(); 
        OrdObj.Name='123456';
        OrdObj.EffectiveDate=System.today();
        OrdObj.Order_Review_Status__c='Pending Approval';
        OrdObj.Delivery_Block__c='YB';
        OrdObj.Assigned_Approver__c = '0051300000BiXKz';
        OrdObj.Status = 'Draft';
        OrdObj.AccountId=Acc.id;
        insert OrdObj;

        Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
        app.setObjectId(OrdObj.id);
        Approval.ProcessResult result = Approval.process(app);


//Get records to unlock
List<order> orderList = [SELECT Id From Order WHERE Name = '123456' ];
//Check locked records
List<order> orderLockList = new List<Order>();
for(Order c :orderList){
if(Approval.isLocked(c.id)){
orderLockList.add(c);
}
}
//Unlock record
if(!orderLockList.isEmpty()){
//Unlock records
List<Approval.UnlockResult> ulrList = Approval.unlock(orderLockList, false);

// Iterate through each returned result
for(Approval.UnlockResult ulr : ulrList) {
if (ulr.isSuccess()) {
//Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked account with ID: ' + ulr.getId());
}
else {
//Operation failed, so get all errors
for(Database.Error err : ulr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Order fields that affected this error: ' + err.getFields());
}
}
}
}
        }
}

Hello!

When an order is created in our org, it automatically submits into an approval process about 7 minutes after creation.
When the approval process is initiated, there is a field update that occurs to fill in the date/time of submission.

I have a trigger that should unlock the record when an update occurs, but it is not firing during the above mentioned automation.
It works perfectly when I manually edit the record.

Here is my code. Am I missing something to make it work when there's a worflow action triggered update?

I'm not a developer, so I don't know much.


trigger Unlock_Order_Pending_Approval on Order (after update) {
//Get records to unlock
List<order> orderList = [SELECT Id From Order WHERE EffectiveDate = TODAY];
//Check locked records
List<order> orderLockList = new List<Order>();
for(Order c :orderList){
    if(Approval.isLocked(c.id)){
        orderLockList.add(c);
    }
}
//Unlock record
if(!orderLockList.isEmpty()){
    //Unlock records
    List<Approval.UnlockResult> ulrList = Approval.unlock(orderLockList, false);
    
    // Iterate through each returned result
    for(Approval.UnlockResult  ulr : ulrList) {
        if (ulr.isSuccess()) {
            //Operation was successful, so get the ID of the record that was processed
            System.debug('Successfully locked account with ID: ' + ulr.getId());
        }
        else {
            //Operation failed, so get all errors                
            for(Database.Error err : ulr.getErrors()) {
                System.debug('The following error has occurred.');                   
                System.debug(err.getStatusCode() + ': ' + err.getMessage());
                System.debug('Order fields that affected this error: ' + err.getFields());
            }
        }
    }
}
}
 
Hello!

I need some help writing an Apex Trigger and I have 0 code knowledge.
I found a very helpful article by Christopher Alun Lewis (http://christopheralunlewis.blogspot.com/2012/09/making-rejection-comments-mandatory-in.html), but because his scenario is a bit different from mine, I'm stuck.

I have a single step approval process on the order object.
The order is created and automatically entered into the approval process.
The approver must then make sure that the OpportunityId field on the Order is populated before approving.

The trigger I am trying to write should say "If OpportunityId is null and Status is changed to Approved, display error and cancel approval process."

Here is what I've edited from Christopher's code so far, but as you can see I have extra stuff in it to find the processinstancesId and check rejectedStatements that I don't  need - I don't know how to make this applicable to me or if what I've already edited is even correct.

SFDC Support doesn't support editing/creating code, so they cannot assist.

Any help would be greatly appreciated!!!


trigger ValidateOpportunity on Order (before update) 
{
  Map<Id, Order> OpportunityId
             = new Map<Id, Order>{};

  for(Order inv: trigger.new)
  {
    /* 
      Get the old object record, and check if the approval status 
      field has been updated to Approved. If so, put it in a map 
      so we only have to use 1 SOQL query to do all checks.
    */
    Order oldInv = System.Trigger.oldMap.get(inv.Id);

    if (oldInv.Status != 'Approved' 
     && inv.Status == 'Approved')
    { 
      OpportunityId.put(inv.Id, inv);  
    }
  }
   
  if (!OpportunityId.isEmpty())  
  {
    // Get the most recent approval process instance for the object.
    // If there are some approvals to be reviewed for approval, then
    // get the most recent process instance for each object.
    List<Id> processInstanceIds = new List<Id>{};
    
    for (Order invs : [SELECT (SELECT ID
                                              FROM ProcessInstances
                                              ORDER BY CreatedDate DESC
                                              LIMIT 1)
                                      FROM Order
                                      WHERE ID IN :rejectedStatements.keySet()])
    {
        processInstanceIds.add(invs.ProcessInstances[0].Id);
    }
      
    // Now that we have the most recent process instances, we can check
    // the most recent process steps for comments.  
    for (ProcessInstance pi : [SELECT TargetObjectId,
                                   (SELECT Id, StepStatus, Comments 
                                    FROM Steps
                                    ORDER BY CreatedDate DESC
                                    LIMIT 1 )
                               FROM ProcessInstance
                               WHERE Id IN :processInstanceIds
                               ORDER BY CreatedDate DESC])   
    {                   
      if ((pi.Steps[0].Comments == null || 
           pi.Steps[0].Comments.trim().length() == 0))
      {
        rejectedStatements.get(pi.TargetObjectId).addError(
          'Operation Cancelled: Please add an Opportunity to the Order before Approving');
      }
    }  
  }
}
Hello!

I'd like to preface this with the fact that I have 0 dev knowledge and struggle to understand all this, so feel free to speak to me like I'm 5 if you can help! :D

I'm trying to implement reCAPTCHA v2 onto my Community Self-Registration page. I've gotten pretty far and I'm still having some trouble, but I have two questions regarding it's functionality to start with (screenshot below).
  1. Is there a way to get rid of the Submit button? I don't want the user's to have to fill out the form, check the reCAPTCHA box, then click the reCAPTCHA "Submit" button, then finally click our Register button. I want the reCAPTCHA to be verified when they check the box.
  2. Will I have to update my Site Key regulary? I saw a concern about it breaking weekly from a couple years ago, and while I don't think it's a valid concern anymore, I want to make sure. I have added the necessary Trusted Sites.

For reference, I followed these two resources:
  • https://www.learncommunitycloud.com/s/article/Implementing-reCAPTCHA-in-Community-Cloud
  • http://varasi.com/salesforce/embedding-google-recaptcha-v2-in-salesforce-lightning-component-to-increase-security/

User-added image
Hi all,

I have never written a trigger before, so I am having some trouble with the "wording".

What I want the Trigger to do:
On user create, update the User Profile ID to "x" if custom user field = "y" or custom user field = "z".

Below is what I have. I can't even save it because my language is wrong, but I'm hoping I'm not too far off:

trigger CommunityProfileUpdate on User (before insert) {
    for (User a : Trigger.new) {
        if(User.Partner_Conatct_User_Type__c = 'Retailer');
        if(User.Partner_Conatct_User_Type__c = 'Distributor'){
            a.ProfileId = '00e13000000jVJm'
        }
    }
}


Thanks in advance for any help!

Melissa
We are launching a community for case creation and our users will occassionally be pausing the flow we used for case creation.
We want the ability to report on these paused interviews so that we can follow up with the customer and ask them about their incomplete claim.

Since the interviews are technically not created records, I know a normal report can't be run, but does anyone know of a workaround that would help automate this so I don't have to manually check my setup menu?

Thanks!
Hello!

I am in no way a developer so I'm having a hard time getting a very simple iframe to work.
I created a custom Visual Force tab in my org to display this page and I just want it to display an outside URL.

This is what I was using and it looks like it's almost there, but it just won't populate the external page and I can't figure out why.

<apex:page showHeader="true">
    <apex:pageBlock >
      <apex:iframe src="https://www.website.com">
     </apex:iframe>
     </apex:pageBlock>
</apex:page>

Does anyone see what is wrong/can let me know what to change?

Thanks!

Melissa
I don't write code, so bear with me.

I have a portion of an Apex Class that pulls a list of records based on record type for Cases. However, I need to add a criteria here that then looks at the received records and only includes the records where a certain field is filled in.

Current code:


List<RecordType> residentialRecordTypes = [SELECT Id
                                           FROM RecordType
                                           WHERE (DeveloperName = 'Residential' OR DeveloperName = 'Carpet' OR DeveloperName = 'Manufacturing_Distribution' OR DeveloperName = 'Residential_Service_Claims' OR DeveloperName = 'Mannington_Rubber')
                                           AND SobjectType = 'Case'
                                           AND Id in: casesByRecordTypeId.keySet()
                                           LIMIT 1];


So I essentially need to add something like:

AND Case.Division__c LIKE 'Residential'

Any idea how I would do this?

Thank you!

Melissa
Hi all,

I have never written a trigger before, so I am having some trouble with the "wording".

What I want the Trigger to do:
On user create, update the User Profile ID to "x" if custom user field = "y" or custom user field = "z".

Below is what I have. I can't even save it because my language is wrong, but I'm hoping I'm not too far off:

trigger CommunityProfileUpdate on User (before insert) {
    for (User a : Trigger.new) {
        if(User.Partner_Conatct_User_Type__c = 'Retailer');
        if(User.Partner_Conatct_User_Type__c = 'Distributor'){
            a.ProfileId = '00e13000000jVJm'
        }
    }
}


Thanks in advance for any help!

Melissa
Hello!

I am in no way a developer so I'm having a hard time getting a very simple iframe to work.
I created a custom Visual Force tab in my org to display this page and I just want it to display an outside URL.

This is what I was using and it looks like it's almost there, but it just won't populate the external page and I can't figure out why.

<apex:page showHeader="true">
    <apex:pageBlock >
      <apex:iframe src="https://www.website.com">
     </apex:iframe>
     </apex:pageBlock>
</apex:page>

Does anyone see what is wrong/can let me know what to change?

Thanks!

Melissa