• Bob_z
  • NEWBIE
  • 150 Points
  • Member since 2011
  • Salesforce Admin

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 85
    Questions
  • 124
    Replies
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);
    }
     
   }

}

 
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.
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
 
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? 
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? 
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}
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 
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? 
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());
            }
        }
    }
    
}

 
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!');

    }
} 

}



 
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!');

    }

} 
}

 
I am recevieing the following error below that just stated happening today July 12. I'm not sure what would cause this error all of a sudden. If anyone can help me where to look for the issue i would appreciate it. It apprears to be coming from an install pacakge that is not active anymore called. Big Machine  for qouting.

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger BMXB.BMX_OpptyHandler caused an unexpected exception, contact your administrator: BMXB.BMX_OpptyHandler: execution of BeforeUpdate caused by: System.QueryException: sObject type 'QConfig__Model__c' is not supported.: Class.QConfig.configOpptyTriggerHandler.copySyncedQuoteIdToModels: line 38, column 1".