• Bob_z
  • NEWBIE
  • 145 Points
  • Member since 2011
  • Salesfroce Admin

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 84
    Questions
  • 123
    Replies
I am trying to update my visualforce code to a Lightning web component so it will render correctly on mobile devices as well as desktops.  I have been looking for examples on Lightning Datatable component references but I can't find any thing to reference extension controllers or how to only render certain records like my visualforce code below..  If i could get some help  on how to convert the code below that would be great.

Visualforce Page
 
<apex:page standardController="Account"   extensions="VF_SiteServicePartnerAllController" lightningStylesheets="true"  >


<style>
      
          .ht{ height:0px;
    vertical-align:middle;
          
          }
              
   </style>
 
<apex:form > 
  <apex:pageBlock >
    <apex:pageBlockTable cellpadding="1" width="100%" columns="2" value="{!sspList}" var="item">

           <apex:column rendered="{!IF(item.Service_Partner_Site_Status__c = 'Active',true,false )}"  >
                 <apex:outputPanel rendered="{!CONTAINS(item.Trade__c, 'Land')}">
                <apex:outputField value="{!item.Supported_Trade__c}" /><br></br>
                <apex:outputLabel value=""><b>Service Partner Assigned to Site</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Primary Contact</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Contact__c}"/><br></br>
                <apex:outputLabel value=""><b>Primary Field  Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Mobile__c}"/><br></br>
                <apex:outputLabel value=""><b>Primary Field Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Email__c}"/><br></br>
                <apex:outputLabel value=""><b>Secondary Contact</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Contact__c}"/><br></br>
                <apex:outputLabel value=""><b>Secondary Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Mobile__c}"/><br></br>
                <apex:outputLabel ><b>Secondary Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Email__c}"/><br></br>
                <apex:outputLabel ><b>Latest Work Order</b></apex:outputLabel><br></br>
                <apex:outputField value="{!Account.Latest_Work_Order__c}"/>
           </apex:outputPanel>
           </apex:column>
           
           <apex:column styleClass="ht" rendered="{!IF(item.Service_Partner_Site_Status__c = 'Active',true,false && CONTAINS(item.Trade__c, 'Land') )}" >
                <apex:outputPanel rendered="{!CONTAINS(item.Trade__c, 'Land')}">
                <apex:outputLabel ><b>Service Partner Owner</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Owner Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner_Mobile__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Main Phone</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Main_Phone__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Owner Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner_Email__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Provider Start Date</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Start_Date__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Provider End Date</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_End_Date__c}"/>
           </apex:outputPanel> 
           </apex:column>

      </apex:pageBlockTable>

    </apex:pageBlock>

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

Apex Controller
// Used on the account page updated 1-31-2020
Public Class VF_SiteServicePartnerAllController{
   private Account acc;
   public List<Site_Service_Partner__c> sspList {get;set;}
   
   public VF_SiteServicePartnerAllController(ApexPages.StandardController sp){
       acc = (Account)sp.getRecord();
       sspList = new List<Site_Service_Partner__c>();
       sspList = [SELECT Id,Name,Site_Account__c,Primary_Field_Contact__c,Service_Partner__c,
                  Service_Partner_Owner__c,Service_Partner_Owner_Mobile__c,Service_Partner_Owner_Email__c,
                  Primary_Field_Email__c,Primary_Field_Mobile__c,Service_Partner_Site_Status__c, 
                  Contracted_Services__c,Secondary_Field_Contact__c,Secondary_Field_Email__c,Secondary_Field_Mobile__c,
                  Service_Partner_Start_Date__c,Service_Partner_End_Date__c,Service_Partner_Main_Phone__c,Service_Line__c,Supported_Service_Lines__c FROM Site_Service_Partner__c WHERE Site_Account__c =: acc.Id    AND  Service_Line__c IN ('Land', 'Snow', 'Land;Snow') AND Service_Partner_Site_Status__c = 'Active'];

    
    Set<Id> bidId = new  Set<Id>();  
    for(Site_Service_Partner__c bs:sspList){
       bidId.add(bs.Id);
    }
     
   }

}

 
  • March 02, 2020
  • Like
  • 0
I have a custom lightning component that works fine in my salesforce org desktop version and it worked fine in the salesforce mobile 1 app, but since they updated there app to the new user UI my map does not render in the lightning component.. The lightning componet uses leaflet maps and I'm not sure if this is a CSS issue or something else.  I'm hopin gsomeone can help me resolve this issue or has heard of this issue and the fix for this rendering problem. Any help would be greatly appreciated
  • February 27, 2020
  • Like
  • 0
I am having an issue with my lightning component or apex class.

It is a account detail page but receiving the below error. I can't seem to find the issue with my code so i am reaching out to anyone that can help me find the issue.
User-added image

Here is my controller and Component Info.

Component
<aura:component controller="AccountDetailsCtrl" implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global">
    <aura:attribute name="acc" type="Account"></aura:attribute>
    <aura:attribute name="recordId" type="String"></aura:attribute>
    
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>

    <aura:handler name="init" action="{!c.doInit}" value="{!this}" />
    <aura:if isTrue="{!v.acc.Division__c || v.acc.Director_of_Operations__r || v.acc.Senior_Account_Manager__r || v.acc.Regional_Field_Manager_Contact__r || v.acc.Account_Manager__r}">





        <div class="slds-box">
            <table class="slds-table slds-table_cell-buffer slds-table_bordered">
                <thead>
                    <tr class="slds-line-height_reset">
                        <th class="division" scope="col">
                            <div class="slds-truncate" title="Division">Division : {!v.acc.Division__c}</div>
                        </th>
                    </tr>
                    <tr class="slds-line-height_reset">
                        <th class="title" scope="col">
                            <div class="slds-truncate" title="Title">Title</div>
                        </th>
                        <th class="name" scope="col">
                            <div class="slds-truncate" title="Name">Name</div>
                        </th>
                        <th class="email" scope="col">
                            <div class="slds-truncate" title="Email">Email</div>
                        </th>
                        <th class="phone" scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th class="mobile" scope="col">
                            <div class="slds-truncate" title="Mobile">Mobile</div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="slds-hint-parent">
                        <td data-label="Director of Operations title">
                            <div class="slds-truncate" title="Director of Operations">Director of Operations</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Director_of_Operations__r.Name}">{!v.acc.Director_of_Operations__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Director_of_Operations__r.Email}">{!v.acc.Director_of_Operations__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Director_of_Operations__r.Phone}">{!v.acc.Director_of_Operations__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Director_of_Operations__r.MobilePhone}">{!v.acc.Director_of_Operations__r.MobilePhone}</div>
                        </td>
                    </tr>
                    <tr class="slds-hint-parent">
                        <td data-label="Senior Account Manager title">
                            <div class="slds-truncate" title="Senior Account Manager">Senior Account Manager</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Senior_Account_Manager__r.Name}">{!v.acc.Senior_Account_Manager__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Senior_Account_Manager__r.Email}">{!v.acc.Senior_Account_Manager__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Senior_Account_Manager__r.Phone}">{!v.acc.Senior_Account_Manager__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Senior_Account_Manager__r.MobilePhone}">{!v.acc.Senior_Account_Manager__r.MobilePhone}</div>
                        </td>
                    </tr>
                    <tr class="slds-hint-parent">
                        <td data-label="District Manager title">
                            <div class="slds-truncate" title="District Manager">District Manager</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Regional_Field_Manager_Contact__r.Name}">{!v.acc.Regional_Field_Manager_Contact__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Regional_Field_Manager_Contact__r.Email}">{!v.acc.Regional_Field_Manager_Contact__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Regional_Field_Manager_Contact__r.Phone}">{!v.acc.Regional_Field_Manager_Contact__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Regional_Field_Manager_Contact__r.MobilePhone}">{!v.acc.Regional_Field_Manager_Contact__r.MobilePhone}</div>
                        </td>
                    </tr>
                    <tr class="slds-hint-parent">
                        <td data-label="Account Manager title">
                            <div class="slds-truncate" title="Account Manager">Account Manager</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Account_Manager__r.Name}">{!v.acc.Account_Manager__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Account_Manager__r.Name}">{!v.acc.Account_Manager__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Account_Manager__r.Name}">{!v.acc.Account_Manager__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Account_Manager__r.Name}">{!v.acc.Account_Manager__r.MobilePhone}</div>
                        </td>
                    </tr>
                    <tr class="slds-hint-parent">
                        <td data-label="Procurement Manager title">
                            <div class="slds-truncate" title="Procurement Manager">Procurement Manager</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Customer_Procurement_Mangager__r.Name}">{!v.acc.Customer_Procurement_Mangager__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Customer_Procurement_Mangager__r.Name}">{!v.acc.Customer_Procurement_Mangager__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Customer_Procurement_Mangager__r.Name}">{!v.acc.Customer_Procurement_Mangager__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Customer_Procurement_Mangager__r.Name}">{!v.acc.Customer_Procurement_Mangager__r.MobilePhone}</div>
                        </td>
                    </tr>
                    <tr class="slds-hint-parent">
                        <td data-label="Finance Contact title">
                            <div class="slds-truncate" title="Procurement Manager">Finance Contact</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Customer_Finance_Contact__r.Name}">{!v.acc.Customer_Finance_Contact__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Customer_Finance_Contact__r.Name}">{!v.acc.Customer_Finance_Contact__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Customer_Finance_Contact__r.Name}">{!v.acc.Customer_Finance_Contact__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Customer_Finance_Contact__r.Name}">{!v.acc.Customer_Finance_Contact__r.MobilePhone}</div>
                        </td>
                    </tr>
                    <tr class="slds-hint-parent">
                        <td data-label="Facilities Manager title">
                            <div class="slds-truncate" title="Procurement Manager">Facilities Manager</div>
                        </td>
                        <td data-label="Name" class="name">
                            <div class="slds-truncate" title="{!v.acc.Customer_Facilities_Manager__r.Name}">{!v.acc.Customer_Facilities_Manager__r.Name}</div>
                        </td>
                        <td data-label="Email" class="email">
                            <div class="slds-truncate" title="{!v.acc.Customer_Facilities_Manager__r.Name}">{!v.acc.Customer_Facilities_Manager__r.Email}</div>
                        </td>
                        <td data-label="Phone" class="phone">
                            <div class="slds-truncate" title="{!v.acc.Customer_Facilities_Manager__r.Name}">{!v.acc.Customer_Facilities_Manager__r.Phone}</div>
                        </td>
                        <td data-label="Mobile" class="mobile">
                            <div class="slds-truncate" title="{!v.acc.Customer_Facilities_Manager__r.Name}">{!v.acc.Customer_Facilities_Manager__r.MobilePhone}</div>
                        </td>
                    </tr>


                </tbody>
            </table>
        </div>

        <!-- SITES -->
        <div style="height: 500px">
            <lightning:datatable
                    keyField="Name"
                    data="{! v.data }"
                    columns="{! v.columns }"
                    hideCheckboxColumn="true"/>
        </div>
        <!-- <div class="slds-box">
            <table class="slds-table slds-table_cell-buffer slds-table_bordered">
                <thead>
                    <tr class="slds-line-height_reset">
                        <th class="division" scope="col">
                            <div class="slds-truncate" title="Site2">Sites : </div>
                        </th>
                    </tr>
                    <tr class="slds-line-height_reset">
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Site">Site</div>
                        </th>
                        <th class="name" scope="col">
                            <div class="slds-truncate" title="Name">Senior Account Manager</div>
                        </th>
                        <th class="email" scope="col">
                            <div class="slds-truncate" title="Name">Account Manager</div>
                        </th>
                        <th class="phone" scope="col">
                            <div class="slds-truncate" title="Name">Regional Field Manager</div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <aura:iteration items="{!v.acc.Site__r}" var="item">
                        <tr class="slds-hint-parent">
                            <td data-label="Name">
                                <div class="slds-truncate" title="Name"><ui:outputText value="{!item.Name}"/></div>
                            </td>
                            <td data-label="Name" class="name">
                                <div class="slds-truncate" title="Name"><ui:outputText value="{!item.Senior_Account_Manager__r.Name}"/></div>
                            </td>
                            <td data-label="Name" class="email">
                                <div class="slds-truncate" title="Name"><ui:outputText value="{!item.Account_Manager__r.Name}"/></div>
                            </td>
                            <td data-label="Name" class="phone">
                                <div class="slds-truncate" title="Name"><ui:outputText value="{!item.Regional_Field_Manager__r.Name}"/></div>
                            </td>
                        </tr>
                    </aura:iteration>
                </tbody>
            </table>
        </div> -->



    </aura:if>
</aura:component>

Controller on the component.bundle
({
    doInit : function(component, event, helper) {

        component.set('v.columns', [
            {label: 'Site', fieldName: 'Name', type: 'text', sortable: true},
            {label: 'Senior Account Manager', fieldName: 'Senior_Account_Manager__r_Name', type: 'text'},
            {label: 'Account Manager', fieldName: 'Account_Manager__r_Name', type: 'text'},
            {label: 'Regional Field Manager', fieldName: 'Regional_Field_Manager__r_Name', type: 'text'}
        ]);

        helper.call(component, component.get('c.getAccount')).then(function(res){
            console.log(res);
            var rows = res[0].Site__r;
            /* Flatten list of rows for display in lightning datatable */
            for (var i = 0; i < rows.length; i++) { 
                var row = rows[i]; 
                //as data columns with relationship __r can not be displayed directly in data table, so generating dynamic columns 
                if (row.Senior_Account_Manager__r) { 
                     //here you assign the related data to new variables
                    if (row.Senior_Account_Manager__r) row.Senior_Account_Manager__r_Name = row.Senior_Account_Manager__r.Name; 
                    if (row.Account_Manager__r) row.Account_Manager__r_Name = row.Account_Manager__r.Name;
                    if (row.Regional_Field_Manager__r) row.Regional_Field_Manager__r_Name = row.Regional_Field_Manager__r.Name;
                } 
            }
            if(res && res.length > 0) {
                component.set('v.acc',res[0]);
                component.set('v.data', rows);
            }
        })
    }
})

Apex Class
public without sharing class AccountDetailsCtrl {

    @AuraEnabled
    public static Object getAccount(){

        return [
            SELECT Id, Division__c,
                Account_Manager__r.Name, Account_Manager__r.Email, Account_Manager__r.Phone, Account_Manager__r.MobilePhone,
                Senior_Account_Manager__r.Name, Senior_Account_Manager__r.Email, Senior_Account_Manager__r.Phone, Senior_Account_Manager__r.MobilePhone,
                Regional_Field_Manager_Contact__r.Name, Regional_Field_Manager_Contact__r.Email, Regional_Field_Manager_Contact__r.Phone, Regional_Field_Manager_Contact__r.MobilePhone,
                Director_of_Operations__r.Name, Director_of_Operations__r.Email, Director_of_Operations__r.Phone, Director_of_Operations__r.MobilePhone,

                Customer_Procurement_Mangager__r.Name, Customer_Procurement_Mangager__r.Email, Customer_Procurement_Mangager__r.Phone, Customer_Procurement_Mangager__r.MobilePhone,
                
                Customer_Finance_Contact__r.Name, Customer_Finance_Contact__r.Email, Customer_Finance_Contact__r.Phone, Customer_Finance_Contact__r.MobilePhone,
                
                Customer_Facilities_Manager__r.Name, Customer_Facilities_Manager__r.Email, Customer_Facilities_Manager__r.Phone, Customer_Facilities_Manager__r.MobilePhone,
                (SELECT Id, Name,
                    Senior_Account_Manager__r.Name, Senior_Account_Manager__r.Email, Senior_Account_Manager__r.MobilePhone, Senior_Account_Manager__r.Phone,
                    Account_Manager__r.Name, Account_Manager__r.Email, Account_Manager__r.MobilePhone, Account_Manager__r.Phone,
                    Regional_Field_Manager__r.Name, Regional_Field_Manager__r.Email, Regional_Field_Manager__r.MobilePhone, Regional_Field_Manager__r.Phone
                FROM Account.Site__r)

            FROM Account
            WHERE Id =:[SELECT AccountId FROM User WHERE Id =:UserInfo.getUserId()].AccountId
        ];
    }
}


 
  • February 24, 2020
  • Like
  • 0
Is there a way to combine both these classes(Account & Case)  into one so i there isn't two seperate classes in my org? I'm not sure how to accimplish this and could use help.

Account class
Public Class VF_SiteServicePartnerAllController{
   private Account acc;
   public List<Site_Service_Partner__c> sspList {get;set;}
   
   public VF_SiteServicePartnerAllController(ApexPages.StandardController sp){
       acc = (Account)sp.getRecord();
       sspList = new List<Site_Service_Partner__c>();
       sspList = [SELECT Id,Name,Site_Account__c,Primary_Field_Contact__c,Service_Partner__c,
                  Service_Partner_Owner__c,Service_Partner_Owner_Mobile__c,Service_Partner_Owner_Email__c,
                  Primary_Field_Email__c,Primary_Field_Mobile__c,Service_Partner_Site_Status__c, 
                  Contracted_Services__c,Secondary_Field_Contact__c,Secondary_Field_Email__c,Secondary_Field_Mobile__c,
                  Service_Partner_Start_Date__c,Service_Partner_End_Date__c,Service_Partner_Main_Phone__c,Trade__c,Supported_Trade__c,trade_value__c  FROM Site_Service_Partner__c WHERE Site_Account__c =: acc.Id    AND  Trade__c IN ('Land', 'Snow', 'Land;Snow') AND Service_Partner_Site_Status__c = 'Active'];

    
    Set<Id> bidId = new  Set<Id>();  
    for(Site_Service_Partner__c bs:sspList){
       bidId.add(bs.Id);
    }
     
   }

}

Case class
//Used on the Case object updated 1-31-2020
Public Class VF_CaseServicePartExtController{
private Case css;
   public List<Site_Service_Partner__c> cseList {get;set;}
   
   public VF_CaseServicePartExtController(ApexPages.StandardController sp){
       css= (Case)sp.getRecord();
       cseList = new List<Site_Service_Partner__c>();
       cseList = [SELECT Id,Name,Case__c,Site_Account__c,Primary_Field_Contact__c,Service_Partner__c,
                  Primary_Field_Email__c,Primary_Field_Mobile__c,Service_Partner_Site_Status__c, Contracted_Services__c,
                  Secondary_Field_Contact__c,Secondary_Field_Email__c,Secondary_Field_Mobile__c,Service_Partner_Owner__c,
                  Trade__c,Supported_Trade__c  FROM Site_Service_Partner__c WHERE Case__c =: css.Id AND Trade__c includes('Land','Snow','Land;Snow') AND Service_Partner_Site_Status__c='Active' ];
    
    Set<Id> bidId = new  Set<Id>();  
    for(Site_Service_Partner__c bs:cseList){
       bidId.add(bs.Id);
    }
     
   }
 

}


 
  • February 20, 2020
  • Like
  • 0
I created a visualforce and a apex class to display junction object child records on an account page. It is working as expected, but i was wonder how can update my apex class to allow the junction object child records to be updated from the account page? I'm not sure how to accomplish this so i am reaching out to the community to see if anyone could help me update my class to support this function. My VF page and class is below.

VF Page:
<apex:page standardController="Account" extensions="VF_SiteServicePartnerLandController" lightningStylesheets="true"  >


<style>
       th{ width: 50%;}       
   </style>
 
    <apex:form > 
  


     <apex:pageBlock >
    
        
        <apex:pageBlockTable cellpadding="5" width="100%" columns="2" value="{!sspList}" var="item">
 
           <apex:column >
           <apex:outputField value="{!item.Supported_Trade__c}"/><br></br>
           <apex:outputLabel value=""><b>Service Partner Assigned to Site</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Primary Contact</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Contact__c}"/><br></br>
                <apex:outputLabel value=""><b>Primary Field  Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Mobile__c}"/><br></br>
                <apex:outputLabel value=""><b>Primary Field Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Email__c}"/><br></br>
                <apex:outputLabel value=""><b>Secondary Contact</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Contact__c}"/><br></br>
                <apex:outputLabel value=""><b>Secondary Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Mobile__c}"/><br></br>
                <apex:outputField value="{!item.Secondary_Field_Email__c}"/>
            
            </apex:column>
           
           
           <apex:column >
           
           <apex:outputLabel value=""><b>Service Partner Owner</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Owner Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner_Mobile__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Main Phone</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Main_Phone__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Owner Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner_Email__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Provider Start Date</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Start_Date__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Provider End Date</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_End_Date__c}"/>
            
            </apex:column>
            
      </apex:pageBlockTable>
   </apex:pageBlock>
 </apex:form>   
 </apex:page>

Apex Class:
// Used on the account page updated 1-31-2020
Public Class VF_SiteServicePartnerLandController{
   private Account acc;
   public List<Site_Service_Partner__c> sspList {get;set;}
   
   public VF_SiteServicePartnerLandController(ApexPages.StandardController sp){
       acc = (Account)sp.getRecord();
       sspList = new List<Site_Service_Partner__c>();
       sspList = [SELECT Id,Name,Site_Account__c,Primary_Field_Contact__c,Service_Partner__c,
                  Service_Partner_Owner__c,Service_Partner_Owner_Mobile__c,Service_Partner_Owner_Email__c,
                  Primary_Field_Email__c,Primary_Field_Mobile__c,Service_Partner_Site_Status__c, 
                  Contracted_Services__c,Secondary_Field_Contact__c,Secondary_Field_Email__c,Secondary_Field_Mobile__c,
                  Service_Partner_Start_Date__c,Service_Partner_End_Date__c,Service_Partner_Main_Phone__c,Trade__c,Supported_Trade__c  FROM Site_Service_Partner__c WHERE Site_Account__c =: acc.Id AND Site_Account__r.Trade__c includes('Land') AND Service_Partner_Site_Status__c = 'Active' ];

    
    Set<Id> bidId = new  Set<Id>();  
    for(Site_Service_Partner__c bs:sspList){
       bidId.add(bs.Id);
    }
     
   }

}

 
  • February 05, 2020
  • Like
  • 0
I am looking for help on a trigger for the case object.
I have three objects Case, Account and a custom object Site_Partner__c

I need help with a trigger or pex class that performs like this:
The Account object has related records from the Site_Partner__c which has a account lokup field Site__c

I need the functionality to perform that when a case record is created the trigger/class finds the Site_Partner__c records associated with the account on the case record and assigns the case ID to the Case___c lookup field on the Site_Partner__c record. I'm just not sure what the best practices solution to this requirement i.e. Trigger, Apex Class or Process builder.
  • January 29, 2020
  • Like
  • 0
I have a visualforce page with contct information such email and mobile phone number. The field is a standard phone numbe rfield on the Contact object but when it is display on my VF page it loses its format. I'm not sure what i can do to correct the rendering so it shows up on my the account object with the correct format. Any help would be greatly appreciated. My code is below.
<apex:page standardController="Account" extensions="SiteServicePartnerExtController" >
    <apex:pageBlock title="My Content">
        
        <value="{!sspList}" var="item">
        <apex:column  value="{!item.Service_Partner__c}"/>
        <apex:column value="{!item.Contracted_Services__c}"/>
        <apex:column value="{!item.Primary_Field_Contact__c}"/>
        <apex:column value="{!item.Primary_Field_Mobile__c}"/>  
        <apex:column value="{!item.Primary_Field_Email__c}"/>
        <apex:column value="{!item.Contracted_Services__c}"/>
        <apex:column value="{!item.Secondary_Field_Contact__c}"/>
        <apex:column value="{!item.Secondary_Field_Mobile__c}"/>
        <apex:column value="{!item.Secondary_Field_Email__c}"/>
      
        </apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Custom controller:
Public Class SiteServicePartnerExtController{
   private Account acc;
   public List<Site_Service_Partner__c> sspList {get;set;}
   
   public SiteServicePartnerExtController(ApexPages.StandardController sp){
       acc = (Account)sp.getRecord();
       sspList = new List<Site_Service_Partner__c>();
       sspList = [SELECT Id,Name,Site_Account__c,Primary_Field_Contact__c,Service_Partner__c,Primary_Field_Email__c,Primary_Field_Mobile__c,Service_Partner_Site_Status__c, Contracted_Services__c,Secondary_Field_Contact__c,Secondary_Field_Email__c,Secondary_Field_Mobile__c  FROM Site_Service_Partner__c WHERE Site_Account__c =: acc.Id];
    
    Set<Id> bidId = new  Set<Id>();  
    for(Site_Service_Partner__c bs:sspList){
       bidId.add(bs.Id);
    }
     
   }

}

​​​​​​​
  • January 18, 2020
  • Like
  • 0
I have an apex extension controller that I'm trying to send to my porduction org but i am getting the following error while validating from the inbound changeset. 
 
System.ListException: List index out of bounds: 1
Stack Trace: Class.AccountMapCtrl.buildAdditionalWhere: line 190, column 1 Class.AccountMapCtrl.getAccounts: line 84, column 1 Class.AccountMapCtrlTest.testAll: line 26, column 1

Here is the test class and my apex extension controller
 
@isTest(SeeAllData=true)

public class AccountMapCtrlTest{
    static testmethod void testAll(){
        Account acc = new Account(
            Name = 'testAcc',
            Description = 'test description',
            Industry = 'information tech',
            Type = 'Press',
            ShippingLatitude = 22.6211,
            ShippingLongitude = 88.4649,
            RecordTypeId = Account.SObjectType.getDescribe().getRecordTypeInfosByName().get('Site').getRecordTypeId()
        );
        insert acc;

        AccountMapCtrl.describePickList('AccountSource');
        AccountMapCtrl.getFields('Account', 'AccountMap_Filters');
        List<AccountMapCtrl.Field> fields = new List<AccountMapCtrl.Field>();
        Schema.FieldSet fieldset = Schema.SObjectType.Account.fieldSets.getMap().get('AccountMap_Filters');
        for(Schema.FieldSetMember member : fieldset.getFields()){
            fields.add(new AccountMapCtrl.Field(member));
        }
        AccountMapCtrl.getAccounts(Json.serialize(fields), null);
        AccountMapCtrl.getVendors(Json.serialize(fields), null);
        AccountMapCtrl.getManagers();
        AccountMapCtrl.getFieldCSV('Account');
    }

}

Controller:
Public Class AccountExtensionController{
   private Account acc;
   public List<Bids_Sent__c> bidsList {get;set;}
   public Map<String,List<Site_Bid_Details__c>>  bidsMap {get;set;}
   public AccountExtensionController(ApexPages.StandardController sc){
       acc = (Account)sc.getRecord();
       bidsList = new List<Bids_Sent__c>();
       bidsList = [SELECT Id,IsAddedToPDF__c,Customer__r.Service_Agreement_Verbiage__c,Site__c,Site__r.Contract_Start_Date__c,Site__r.Contract_End_Date__c,Site__r.Customer_Location_ID__c,Service_Year__c,Customer__r.Contract_Start_Date__c,Name,Customer__r.Contract_End_Date__c,Site__r.Name,Customer__r.Name,Primary_Contact__r.FirstName,Site__r.BillingCity,Site__r.BillingState,Site__r.BillingStreet,Site__r.BillingPostalCode  FROM Bids_Sent__c WHERE Awarded__c =: acc.Id AND IsAddedToPDF__c=true];
    
    Set<Id> bidId = new  Set<Id>();  
    for(Bids_Sent__c bs : bidsList){
       bidId.add(bs.Id);
    }
     
    bidsMap = new Map<String,List<Site_Bid_Details__c>> ();
    for(Site_Bid_Details__c bd : [SELECT Id, Bid_Name__r.Name,Site__c,Contract_Start_Month__c,Site__r.Customer_Location_ID__c,Cost__c,Customer__r.Contract_Month__c,Increment__c,Total__c,Price__c,Scope__c,Bid_Name__r.Service_Type__c,Number_of_Months__c,Retainer_Fee__c,Monthly_Payment__c,UOM__c  FROM Site_Bid_Details__c WHERE Bid_Name__c IN : bidId]){
        
        if(bidsMap.containsKey(bd.Bid_Name__r.Name)){
  System.debug('CONTAINS KEY: ' + bd.Bid_Name__r.Name);
  bidsMap.get(bd.Bid_Name__r.Name).add(bd);
} else { 
  System.debug('CREATE: ' + bd.Bid_Name__r.Name);
  bidsMap.put(bd.Bid_Name__r.Name,new List<Site_Bid_Details__c>{bd}); 
}
    } 

}

}

​​​​​​​
  • January 13, 2020
  • Like
  • 0
I am working on a flow wrapped in a lightning component as a global action and i am trying to figure out how to change the finish bahavior so the user is redirected to the home page. I came across these events ( force:navigateToObjectHome or force:navigateToUrl.) but I'm not sure where to used them in my lightning component. Any help with this would be greatly appreciated. My code is below for my component. 

Component:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global" >

<aura:handler name="init"  value="{!this}" action="{!c.init}" />
<lightning:flow aura:id="flowData" />
</aura:component>

Controller:
 
({
init : function (component) {
// Find the component whose aura:id is "flowData"
var flow = component.find("flowData");
// In that component, start your flow. Reference the flow’s Unique Name.
flow.startFlow("New_IT_Support_Case");
   
},
})

Helper:
({
	helperMethod : function() {
		
	}
})



 
  • January 08, 2020
  • Like
  • 0
I have created a flow to create new case records and I'm trying to add the file upload component to attach files. When I run the debug to see if it is working. The screen to upload files is greyed out.  I'm not sure if i have the setup correct. please any help to get this working would be greatly appreciated. 

User-added image

Component Setup
User-added image
 
  • January 03, 2020
  • Like
  • 0
Im trying to figure out if there is a way create new case comments from email to case Thread ID.   I want this to work like salesforce cases work. When a salesforce agent sends me an email and I reply to the email the support case updates with my comments. Is there a way to do this? 
  • December 09, 2019
  • Like
  • 0
I am working on a new flow for a case object and I'm running into an issue.

I am using the Case Reason field as a controlling picklist to six other picklist. I can not figure out how to add all six picklist and have the Case Reason field control them on one flow screen. If anyone has a solution for this issue i would be very greatful for some help.
  • December 09, 2019
  • Like
  • 0
My company has an custom heat map that works fine in the old salesforce mobile app for ipad, but when i turn on the new permission set for the new salesforce mobile app the custom heat map does not render correctly. Users can not see the map. I just wondering what could cause this issue. 

User-added imageIt looks like this is a sizing issue like an iframe but i'm not sure.

This is the way it should look.

User-added image
  • November 15, 2019
  • Like
  • 0
My company has an custom heat map that works fine in the old salesforce mobile app for ipad, but when i turn on the new permission set for the new salesforce mobile app the custom heat map does not render correctly. Users can not see the map. I just wondering what could cause this issue. 

User-added image
It looks like this is a sizing issue like an iframe but i'm not sure.

This is the way it should look.

User-added image
  • November 14, 2019
  • Like
  • 0
I am working on a Case object flow and I am having a problem trying to figure out how to get a dependent multi-select picklist. I am using the dependent lightning component for cointrolling field category and the dependent field (multi-select picklist) services.  

Is there a way to show all the value in the multi select picklist when I select a value from the controlling picklist? 

Also, is there a way to show those value in the multi select picklist as checkboxes on the flow screen for users? 
  • October 04, 2019
  • Like
  • 0
I have a visualforce page using a standard account object. I also have a child custom object Bids_Sent__c. There is an account lookup field on the related child object titled "Awarded__c".   In my visualforce page i want to some how reference a field Service_Agreement_Verbiage__c on the Bids_Sent__c object. The child relationship name for Bids_Sent__c lookup field "Awarded__c" is "Bids_Sent4". Below I tried this mapping on my VF page and I get the following error.
Error: Unknown property 'VisualforceArrayList.Service_Agreement_Verbiage__c'

{!Account.Bids_Sent4__r.Service_Agreement_Verbiage__c}
  • September 17, 2019
  • Like
  • 0
I am trying to create a formula that compares a date field Like Acme_Date__c = TODAY() then display "TODAY" for atext value. 

I'm not sure how to accomplish this result without getting errors 
  • September 10, 2019
  • Like
  • 0
I have a currency formula field and I wonddering if my formula below is correct to round the value to a whole number? I am trying to remove the cent values $2,022.23 should be 2,022.00

ROUND(Price__c - Price__c * Acceptable_High_Margin__c,0)
  • August 16, 2019
  • Like
  • 0
I have a visualforce page and the standard object is the Account. I'm trying to map a field from the related child record to the account visualforce page.

I'm not sure how to map the field {!Account.Bids_Sent__c.Test__c} on the visualforce page. 

 I am getting the following error.

Error: Invalid field Bids_Sent__c for SObject Account
 
  • August 16, 2019
  • Like
  • 0
I'm having a problem with getting a formula field to calculate the correct percentage. I have 3 fields    Cost (currency field) Number of Months(Number Field) Retainer(Percent Field)

I'm trying to create a formula that shows the results of
Cost__c * Number_Of_Months__c - Retainer__c

But when i view the Total__c field, My formula is only reducing the amount by the number I enter into the retainer field.

So I enter 1,000 into the cost field and 5 in the number of months  field and 5 percent in the retainer field  my return value is $4,999.95 not 4,750. Can any one help me with this formula? 
  • August 05, 2019
  • Like
  • 0
I created a visualforce and a apex class to display junction object child records on an account page. It is working as expected, but i was wonder how can update my apex class to allow the junction object child records to be updated from the account page? I'm not sure how to accomplish this so i am reaching out to the community to see if anyone could help me update my class to support this function. My VF page and class is below.

VF Page:
<apex:page standardController="Account" extensions="VF_SiteServicePartnerLandController" lightningStylesheets="true"  >


<style>
       th{ width: 50%;}       
   </style>
 
    <apex:form > 
  


     <apex:pageBlock >
    
        
        <apex:pageBlockTable cellpadding="5" width="100%" columns="2" value="{!sspList}" var="item">
 
           <apex:column >
           <apex:outputField value="{!item.Supported_Trade__c}"/><br></br>
           <apex:outputLabel value=""><b>Service Partner Assigned to Site</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Primary Contact</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Contact__c}"/><br></br>
                <apex:outputLabel value=""><b>Primary Field  Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Mobile__c}"/><br></br>
                <apex:outputLabel value=""><b>Primary Field Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Primary_Field_Email__c}"/><br></br>
                <apex:outputLabel value=""><b>Secondary Contact</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Contact__c}"/><br></br>
                <apex:outputLabel value=""><b>Secondary Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Secondary_Field_Mobile__c}"/><br></br>
                <apex:outputField value="{!item.Secondary_Field_Email__c}"/>
            
            </apex:column>
           
           
           <apex:column >
           
           <apex:outputLabel value=""><b>Service Partner Owner</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Owner Cell</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner_Mobile__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Main Phone</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Main_Phone__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Partner Owner Email</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Owner_Email__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Provider Start Date</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_Start_Date__c}"/><br></br>
                <apex:outputLabel value=""><b>Service Provider End Date</b></apex:outputLabel><br></br>
                <apex:outputField value="{!item.Service_Partner_End_Date__c}"/>
            
            </apex:column>
            
      </apex:pageBlockTable>
   </apex:pageBlock>
 </apex:form>   
 </apex:page>

Apex Class:
// Used on the account page updated 1-31-2020
Public Class VF_SiteServicePartnerLandController{
   private Account acc;
   public List<Site_Service_Partner__c> sspList {get;set;}
   
   public VF_SiteServicePartnerLandController(ApexPages.StandardController sp){
       acc = (Account)sp.getRecord();
       sspList = new List<Site_Service_Partner__c>();
       sspList = [SELECT Id,Name,Site_Account__c,Primary_Field_Contact__c,Service_Partner__c,
                  Service_Partner_Owner__c,Service_Partner_Owner_Mobile__c,Service_Partner_Owner_Email__c,
                  Primary_Field_Email__c,Primary_Field_Mobile__c,Service_Partner_Site_Status__c, 
                  Contracted_Services__c,Secondary_Field_Contact__c,Secondary_Field_Email__c,Secondary_Field_Mobile__c,
                  Service_Partner_Start_Date__c,Service_Partner_End_Date__c,Service_Partner_Main_Phone__c,Trade__c,Supported_Trade__c  FROM Site_Service_Partner__c WHERE Site_Account__c =: acc.Id AND Site_Account__r.Trade__c includes('Land') AND Service_Partner_Site_Status__c = 'Active' ];

    
    Set<Id> bidId = new  Set<Id>();  
    for(Site_Service_Partner__c bs:sspList){
       bidId.add(bs.Id);
    }
     
   }

}

 
  • February 05, 2020
  • Like
  • 0
I am looking for help on a trigger for the case object.
I have three objects Case, Account and a custom object Site_Partner__c

I need help with a trigger or pex class that performs like this:
The Account object has related records from the Site_Partner__c which has a account lokup field Site__c

I need the functionality to perform that when a case record is created the trigger/class finds the Site_Partner__c records associated with the account on the case record and assigns the case ID to the Case___c lookup field on the Site_Partner__c record. I'm just not sure what the best practices solution to this requirement i.e. Trigger, Apex Class or Process builder.
  • January 29, 2020
  • Like
  • 0
I have created a flow to create new case records and I'm trying to add the file upload component to attach files. When I run the debug to see if it is working. The screen to upload files is greyed out.  I'm not sure if i have the setup correct. please any help to get this working would be greatly appreciated. 

User-added image

Component Setup
User-added image
 
  • January 03, 2020
  • Like
  • 0
Im trying to figure out if there is a way create new case comments from email to case Thread ID.   I want this to work like salesforce cases work. When a salesforce agent sends me an email and I reply to the email the support case updates with my comments. Is there a way to do this? 
  • December 09, 2019
  • Like
  • 0
I am working on a Case object flow and I am having a problem trying to figure out how to get a dependent multi-select picklist. I am using the dependent lightning component for cointrolling field category and the dependent field (multi-select picklist) services.  

Is there a way to show all the value in the multi select picklist when I select a value from the controlling picklist? 

Also, is there a way to show those value in the multi select picklist as checkboxes on the flow screen for users? 
  • October 04, 2019
  • Like
  • 0
I have a visualforce page using a standard account object. I also have a child custom object Bids_Sent__c. There is an account lookup field on the related child object titled "Awarded__c".   In my visualforce page i want to some how reference a field Service_Agreement_Verbiage__c on the Bids_Sent__c object. The child relationship name for Bids_Sent__c lookup field "Awarded__c" is "Bids_Sent4". Below I tried this mapping on my VF page and I get the following error.
Error: Unknown property 'VisualforceArrayList.Service_Agreement_Verbiage__c'

{!Account.Bids_Sent4__r.Service_Agreement_Verbiage__c}
  • September 17, 2019
  • Like
  • 0
I am trying to create a formula that compares a date field Like Acme_Date__c = TODAY() then display "TODAY" for atext value. 

I'm not sure how to accomplish this result without getting errors 
  • September 10, 2019
  • Like
  • 0
I'm having a problem with getting a formula field to calculate the correct percentage. I have 3 fields    Cost (currency field) Number of Months(Number Field) Retainer(Percent Field)

I'm trying to create a formula that shows the results of
Cost__c * Number_Of_Months__c - Retainer__c

But when i view the Total__c field, My formula is only reducing the amount by the number I enter into the retainer field.

So I enter 1,000 into the cost field and 5 in the number of months  field and 5 percent in the retainer field  my return value is $4,999.95 not 4,750. Can any one help me with this formula? 
  • August 05, 2019
  • Like
  • 0
I was wondering if there is a way to create mutiple child records for an opportunity by using a number field on the opportunity record? 

Below I am using this trigger to create new products, but if a user wants to add more products my code looks at that field and creates the number of product that match that number field. Iwant to give them the ability to add mor eproducts to the opportunity record if needed and I can't figure out how to update my trigger to do so that is why i am wondering if there's a way to do this with a Flow instead. 

If anyone can give me advice to either update my trigger to accomadate this request or how to create that flow I would greatly appreciate it.

Thanks,
Bob
 
trigger tr_MultiProductsCreated on Opportunity  (after insert, after update) 
{
  
   List<Yushin_Product__c> ProductRecordsFinalListToInsert = New List<Yushin_Product__c>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate)
    {
        For(Opportunity opp : Trigger.New)
        {
            If(opp.Product_Qauntity__c != null)
            {
                List<Yushin_Product__c> fetchingAlreadyExistsedRecords = [Select Id FROM Yushin_Product__c WHERE Opportunity__c =:opp.Id];
                
                If(fetchingAlreadyExistsedRecords.IsEmpty())
                {
                    // I need to create more records if a new number is added to the field.
                    For(Integer I = 0; I < opp.Product_Qauntity__c; I++)
                    {
                        Yushin_Product__c prd = New Yushin_Product__c();
                        
                        prd.Opportunity__c = opp.Id;
                        ProductRecordsFinalListToInsert.add(prd);
                    }
                }
                
            }
            
            try{
                If(!ProductRecordsFinalListToInsert.IsEmpty()){
                    insert ProductRecordsFinalListToInsert;
                }
            }
            Catch(Exception e){
                System.debug('The thrown exception for CreatingAutoRecords is:: ' + e.getMessage());
            }
        }
    }
    
}

 
  • July 11, 2019
  • Like
  • 0
I created a trigger that  display an error message if the owner of a opportunity tries to enter the same number in a field that is already on another record. My trigger below is working mostly. The message shows at the field level when there is another opportunity with the same number, but if i create an  opportunity and do not enter a number ( so the field is null/blank). Then go back into the record
and try to add a number it gives me the error message no matter what number I enter into the field. I'm not sure how to get the trigger to allow a user to enter a number in the field after it's been created without getting the error. Any help would be greatly appreciated.
 
trigger TR_RejectDupPriority on Opportunity (before insert, before update) {
    
    //Display error message if another opportunity has the same number in Quting_Priority__c field

 Set<decimal> oppSet = new Set<decimal>();

 for(Opportunity o : trigger.new){

     oppSet.add(o.Quting_Priority__c);
       
}

 //query all existing record for quoteprioritynum__c
 List<Opportunity> oppsList = [SELECT id,Owner.Profile.Name, Owner.Id,
 Quting_Priority__c, LastModifiedBy.Id, quoteprioritynum__c 
      FROM Opportunity 
      WHERE Quting_Priority__c in :oppSet AND 
 Owner.Id = :userinfo.getuserid()];
   
    //ignore system admins
    Profile pr = [select id from Profile where name='System Administrator'];
  
  if(UserInfo.getProfileId()!=pr.id)
for(Opportunity o:trigger.new) 
    
{
    //Check Update for dupe numbers
    if(Trigger.isUpdate && 
    Trigger.oldmap.get(o.id).Quting_Priority__c!=o.Quting_Priority__c
     && o.LastModifiedBy.Id == o.Owner.Id)
       
    {
       o.Quting_Priority__c.adderror('Another quote has the same priority number, please enter a new number!');
    }

    //Only check for priority size
    if(Trigger.isInsert && o.Quting_Priority__c==o.Quting_Priority__c
         && oppsList.size()>0 && o.LastModifiedBy.Id == o.Owner.Id)
       
    {
       o.Quting_Priority__c.adderror('Another quote has the same priority number, please enter a new number!');

    }
} 

}



 
  • June 24, 2019
  • Like
  • 0
I created a trigger that should display an error message if the owner of a opportunity tries to enter the same number in a field that is already on another record. Ny trigger below is working somewhat. The message shows at the field level when there is another opportunity with the same number, but it shows the error message regardless of who owns the record. I'm not sure how to get the trigger to reconize that the user trying to enter the number is the same as the owner. 

I first tried using "integer" in my set collection, but when i tried to compile I recieved the following error message
Invalid bind expression type of String for column of type Decimal
So I create a formula field (quoteprioritynum__c) and use TEXT to get this to work with Set<string><string> I tried a few things but I wasn't able to save my trigger successfully. 

So I'm stuck with the trigger half working. Any help would be greatly appreciated. 
 
trigger TR_RejectDupPri on Opportunity (before insert,before update) {
//Display error message if another opportunity has the same number in Quting_Priority__c field

 Set<string> oppSet = new Set<string>();

 for(Opportunity o : trigger.new){

     oppSet.add(o.quoteprioritynum__c);
       
 }

 //query all existing record for quoteprioritynum__c
 List<Opportunity> oppsList = [select id, Owner.Id,Quting_Priority__c,LastModifiedBy.Id,quoteprioritynum__c from Opportunity where quoteprioritynum__c in :oppSet];

for(Opportunity o:trigger.new) 
{
    //Update
    if(Trigger.isUpdate && o.quoteprioritynum__c==o.quoteprioritynum__c && oppsList.size()>0 && Trigger.oldmap.get(o.id).quoteprioritynum__c!=o.quoteprioritynum__c && o.LastModifiedBy.Id == o.Owner.Id )
    {
       o.Quting_Priority__c.adderror('Another quote has the same priority number, please enter a new number!');
    }

    //Only check for size
    if(Trigger.isInsert && o.quoteprioritynum__c==o.quoteprioritynum__c && oppsList.size()>0 && o.LastModifiedBy.Id == o.Owner.Id)
    {
       o.Quting_Priority__c.adderror('Another quote has the same priority number, please enter a new number!');

    }

} 
}

 
  • June 19, 2019
  • Like
  • 0
I have created a new opportunity button to create products. The button is working, but it keeps returning back to the beginning of the flow.

How would I change that behavor in the link to returning back to the opportunity record?

https://acme.lightning.force.com/flow/Create_Yushin_Products?recordId={!Opportunity.Id}

User-added image
  • May 17, 2019
  • Like
  • 0