• Bob_poliquin
  • NEWBIE
  • 135 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 72
    Questions
  • 116
    Replies
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
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
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 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)
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
 
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 have a button on the account object, when a user clicks on it, it launches a visuaforce page as a PDF document. I am trying to figure out how do I get this docuemnt to be created, but i want the users to be able to select the related records then launch the visualforce page with the selected records shown to download as a document. 

I'm not sure how this can be accomplished, Apex, Flow, Process Builder, etc.  Any help on this would be greatly appreciated.

Visualforce Page:
 
<apex:page standardcontroller="Account" renderas="pdf" extensions="AccountExtensionController" standardstylesheets="false" showheader="false" applyhtmltag="false">
<form >
<html xmlns="http://www.w3.org/1999/xhtml">
    <body style="color:#000000;border-style:solid; border-width:0px; width:85%; text-align:center">
    </body>

    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif;text-align:left;"
               cellpadding="2">
            
            <tr>
                <td colspan="4" style="font-size:12px; font-weight: normal">
                </td>
            </tr>
            
            <tr>
                <td colspan="4" style="font-weight:bold ; border-style:solid; border-width:1px;
                border-color:#000000;padding:3px;text-align:center;background-color:#B4C6E7">
                    SERVICE PARTNER DETAILS
                </td>
            </tr>

    </table>
            
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif; text-align:left;"
               cellpadding="2">
            <tr>
                <td width="50%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px;padding-top:10px">
                    <b>Company</b> {!Account.Name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                <td width="50%" align="right" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color:#ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px;padding-top:10px">
                    <b>Office Phone</b> {!Account.Phone}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <tr>
                <td width="25%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px">
                    <b>Contact</b> {!Account.Primary_Field_POC__r.FirstName} {!Account.Primary_Field_POC__r.LastName} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                <td width="25%" align="left" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color:  #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px"><b>Cell Phone</b> {!Account.Secondary_Phone__c}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            <tr>
                <td width="25%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px">
                    <b>Street Address</b><br/> {!Account.BillingStreet}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                <td width="25%" align="left" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color:#ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px"><b>Fax</b> {!Account.Fax}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            
            <tr>
                <td width="25%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px">
                    <b>City, St. Zip</b><br/> {!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td width="25%" align="left" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color: #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding-bottom:10px"><b>Email</b> {!Account.Primary_Field_POC__r.Email}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="4" style="font-weight:bold ; border-style: solid; border-width:1px;
                border-color: #000000;padding:3px;padding:3px;text-align:center;background-color:#B4C6E7">PER PUSH FEE SERVICE AGREEMENT</td>
            </tr>
    </table>
            
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif;  text-align:left;"
               cellpadding="4">
          
            <tr>
               
            <td width="50%" align="left" style="color: #000000;text-align:center; border-right-style: solid; border-right-width: thin;
                border-right-color: #ffffff;font-style:normal; font-weight:normal;font-size:12px;padding:3px">Per Push Fees: Includes all fees necessary to complete the services described in the scope of work for the event duration.  Hourly pricing applies only to extra services.
            </td>
            </tr>
    </table>
 
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif;   text-align:center;"
               cellpadding="2">
            
            <tr>
                <td colspan="4" style="font-size:12px; font-weight: normal">
                </td>
            </tr>
            
            <tr>
                <td colspan="4" style="font-weight:bold ; border-style: solid; border-width:1px;
                border-color:#000000;padding:3px;background-color:#B4C6E7;">
                  Service Locations and Fees
                </td>
            </tr>
        <tr><td></td></tr>
    </table>
   
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif; text-align:left;"
               cellpadding="0">
              
            <apex:repeat var="sd" value="{!bidsList}">
            


                    <tr>
                        <th style="text-align:center;background-color:#d9d9d9;border-bottom-style:solid;border-bottom-width:1px;border-top-width:1px; border-top-style:solid">Site Name</th>
                        <th style="text-align:center;background-color:#d9d9d9;border-bottom-style:solid;border-bottom-width:1px;border-top-width:1px; border-top-style:solid">Service Period</th>
                        <th style="text-align:center;background-color:#d9d9d9;border-bottom-style:solid;border-bottom-width:1px;border-top-width:1px;border-top-style:solid">Address</th>
                    </tr>
                   
                   <tr>

                        <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2" > {!sd.Customer__r.Name }</td>
                        <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2" ><apex:outputText value="{0, date, MMMM d','  yyyy}">
                        <apex:param value="{!sd.Customer__r.Contract_Start_Date__c}" /> </apex:outputText> - <apex:outputText value="{0, date, MMMM d','  yyyy}">
                        <apex:param value="{!sd.Customer__r.Contract_End_Date__c}" /> 
</apex:outputText> </td>
                        <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2" >{!sd.Site__r.BillingStreet}<br/>{!sd.Site__r.BillingCity}, {!sd.Site__r.BillingState} {!sd.Site__r.BillingPostalCode} </td></tr>

                <apex:repeat var="et" value="{!bidsMap[sd.Name] }"  >
    
                   <tr>
                       <th style="text-align:center;background-color:#d9d9d9;border-bottom-style:solid;border-bottom-width:1px;border-top-width:0px; border-top-style:solid">Service Type</th>
                       <th style="text-align:center;background-color:#d9d9d9;border-bottom-style:solid;border-bottom-width:1px;border-top-width:0px; border-top-style:solid">Service Desciption</th>
                       <th style="text-align:center;background-color:#d9d9d9;border-bottom-style:solid;border-bottom-width:1px;border-top-width:0px; border-top-style:solid">Pricing Schedule</th>
                   
                   </tr>

                   <tr>
                        <td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;text-align:center" class="ctr"> {!et.Bid_Name__r.Service_Type__c}</td>
                        <td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;text-align:center;text-align:center" class="ctr">{!et.Scope__c} <br/>  {!et.Increment__c}</td>
                        <td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;text-align:center;text-align:center" class="ctr"> ${!et.Price__c}</td>
                   </tr>

                </apex:repeat>
                
            </apex:repeat>
           </table>
        
    </html>

</form>


</apex:page>



 
I am getting the following error when i try to preview my visualforce page. "Map key a0Mf4000009Yd63 not found in map
Error is in expression '{!bidsMap[sd.Name]}' in component <apex:repeat> in page test_awarded" I not sure where I'm going wrong and help would be greatly appreciated.

visualforce page:
<apex:page standardcontroller="Account"  extensions="AccountExtensionController"  standardstylesheets="false" showheader="false" applyhtmltag="false">
<form >
<html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    </body>
    
 
   
 
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif; border-collapse: collapse;  text-align:center;"
               cellpadding="2">
             <apex:repeat var="sd" value="{!bidsList}">
                   
<tr>
<td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;" class="ctr"> {!sd.Name}</td>

<td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;" class="ctr">${!sd.Site__r.Name}</td></tr>

<apex:repeat var="et" value="{!bidsMap[sd.Name]}"  >
<tr>
<td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;" class="ctr"> {!et.Scope__c} {!et.Increment__c}</td>

<td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;" class="ctr">${!et.Price__c}</td>

<td style="border-bottom:solid;border-bottom-color:#000000;border-bottom-width:1px;" class="ctr">${!et.Bid_Name__r.Name}</td>
</tr>
  </apex:repeat>

</apex:repeat>
            </table></html>

</form>


</apex:page>




Apex Code:
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,Name,Site__r.Name FROM Bids_Sent__c WHERE Awarded__c =: acc.Id];
    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,Increment__c,Price__c FROM Site_Bid_Details__c WHERE Bid_Name__c IN : bidId]){
        if(bidsMap.containsKey(bd.Bid_Name__r.Name)){
           bidsMap.get(bd.Bid_Name__r.Name).add(bd);
        }
        else{
            bidsMap.put(bd.Bid_Name__r.Name,new List<Site_Bid_Details__c>{bd});
        }
    } 

}

}

 
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 created a flow and added it to a visualforce page so i can use it on a force.com site to use as a web form. Some of my input fields are lightning components, so when i go to the site the fields that have the lightning components gives me the dredged "We can’t display component 'flowruntime:phone', because it isn't supported in Classic runtime. Ask your Salesforce admin to distribute this flow in Lightning runtime instead".

I created this aura component after viewing a few articles, but I only get a error and my visualforce page does not display anything. 

Any help with this would be greatly appreciated.

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

Visualforce Page:
 
<apex:page showHeader="false" sidebar="false" lightningStylesheets="true" standardStylesheets="false" standardController="SP_Application__c" >
  
 <html>
      <head>
         <apex:includeLightning  />
         
        
      </head>
      <body class="slds-scope">
         <div class="slds-scope">                                                 
         <div id="flowContainer" />
         <script src="https://acme-dev-ed.lightning.force.com/lightning/lightning.out.js"></script>
<script>$Lightning.use("c:lightningcreatecomponent", function() {
   $Lightning.createComponent("lightning:flow", {},
      "flowContainer",
      function (component) {
         component.startFlow("Service_Provider_Application", inputVariables);
      })
   ;}
);
</script>
         </div>
      </body>
   </html>
</apex:page>




 
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
I have a flow that I embedded into a visualforce page, but I am getting the following error. "can’t display component 'flowruntime:dependentPicklists', because it isn't supported in Classic runtime". I was wondering if I render lightning flow runtime into my visualforce page would this solve my issue?  I have never tried this before, if anyone could show how to add the code to my visualforce page below that would be greatly appreciated.

 
<apex:page standardController="Opportunity" lightningStylesheets="true" >
    <flow:interview name="Create_Yushin_Products" finishLocation="/{!Opportunity.Id}">
        <apex:param name="recordId" value="{!Opportunity.Id}" />
    </flow:interview>
</apex:page>

 
I am trying to create a new flow with a rich text component (NewRichTextCop), but it is not showing up in my flow builder. 

Has anyone seen this before?

User-added image
In flow builder my screen has a button entitled Finish, but when i run the flow it changes to Next?  My flow is just a form a user will fill-out so i want the button to stay Finish, but i can't figure out how to get my running flow's button to display anything other than next? 

User-added image
User-added image
I have a flow that creates multiple records at once. The last record I am trying to create has record types and with each record types. When i try to create a specific record "Software" by running the flow it give me the following error.

Error Occurred: This error occurred when the flow tried to create records: INVALID_FIELD_FOR_INSERT_UPDATE: Yushin_Product__c: bad field names on insert/update call: Brief_description_of_the_modification__c, Current_running_program__c, New_Errors__c.

I'm guessing this is caused by not having the record type that would associate the new software record and fields on the page.

I've tried a few different things but nothing seems to work. I am working in the new Flow Builder UI, so anything i find online doesnt match my option because the screenshot are from the old version of flow. 

below ar escreenshot of my flow. Any help would be greatly appreciated.

Account record creation
User-added image

Opportunity Creation
User-added image

Software record creation

User-added image
 
I am having a issue with finding a solution to a visualforce page i created.  it is a web form via force.com site and I am trying to make any field on the form read only if there is a value in that field. I created a sample web form ( code is below) to hopefully have someone help resolve this issue.  In my sample i have javascript, but that doesnt seem to work either. What am I doing wrong? Any help would be greatly appreciated.

Link to sample record (https://mymerchandiseco-developer-edition.na39.force.com/ap?id=a0t0L0000051CZ0):

Code for visualforce page:
<apex:page doctype="html-5.0" sidebar="false" showheader="false" cache="false" standardcontroller="ACME_Product__c" >
    <apex:form id="theform">
        <apex:pageMessages />
        <html>
        <style>
            ::-webkit-input-placeholder {
                color: blue;
            }

            div {
                border-bottom: solid;
                border-bottom-color: #000000;
                border-width: 1px;
                padding-top: 25px;
                padding-bottom: 3px;
                padding-left: 10px;
            }

            th {
                padding-left: 20px;
                margin-left: 10px;
                padding-top: 5px;
            }

            td {
                padding-left: 20px;
            }


            input, textarea {
                padding: 9px;
                border: solid 1px #E5E5E5;
                outline: 0;
                font: normal 13px/100% Verdana, Tahoma, sans-serif;
                background: #FFFFFF url('bg_form.png') left top repeat-x;
                background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
                background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
                box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
                -moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
                -webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
            }

            textarea {
                width: 250px;
                max-width: 250px;
                height: 100px;
                line-height: 150%;
            }

                input:hover, textarea:hover,
                input:focus, textarea:focus {
                    border-color: #C9C9C9;
                    -webkit-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 8px;
                }

            .form label {
                margin-left: 10px;
                color: #999999;
            }

            .submit input {
                width: auto;
                padding: 9px 15px;
                background: #617798;
                border: 0;
                font-size: 14px;
                color: #FFFFFF;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
            }

            img {
                display: block;
                margin-left: auto;
                margin-right: auto;
                padding-top: 20px;
            }


            p {
                display: block;
                margin-left: auto;
                margin-right: auto;
                text-align: center;
                font-size: 15px;
            }
        </style>
        <head>
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
        </head>

        <body>

           <div><h2>Information</h2></div>
            <table>

                <tr><th>Model #</th></tr>
                <tr>
                    <td>
                        <apex:inputField value="{!ACME_Product__c.Product_Model__c}" />
                    </td>
                </tr>

                <tr><th>Serial Number</th></tr>
                <tr>
                    <td>
                        <apex:inputField id="serial" value="{!ACME_Product__c.Serial_Number__c}" />
                    </td>
                </tr>
                <tr><th>Discharge Direction</th></tr>
                <tr>
                    <td>
                        <apex:inputField value="{!ACME_Product__c.Product_Options__c}" />
                    </td>
                </tr>

</table>
        </body>
    </html>
</apex:form>
<script>
    var serial = document.getElementById("{!$Component.theform.serial}");

    if (this.value != 0) {
        serial.disabled = true;
    } else {
        serial.disabled = false;
    }
        }
</script>
</apex:page>

 
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 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
I am trying to create a new flow with a rich text component (NewRichTextCop), but it is not showing up in my flow builder. 

Has anyone seen this before?

User-added image
I have a flow that creates multiple records at once. The last record I am trying to create has record types and with each record types. When i try to create a specific record "Software" by running the flow it give me the following error.

Error Occurred: This error occurred when the flow tried to create records: INVALID_FIELD_FOR_INSERT_UPDATE: Yushin_Product__c: bad field names on insert/update call: Brief_description_of_the_modification__c, Current_running_program__c, New_Errors__c.

I'm guessing this is caused by not having the record type that would associate the new software record and fields on the page.

I've tried a few different things but nothing seems to work. I am working in the new Flow Builder UI, so anything i find online doesnt match my option because the screenshot are from the old version of flow. 

below ar escreenshot of my flow. Any help would be greatly appreciated.

Account record creation
User-added image

Opportunity Creation
User-added image

Software record creation

User-added image
 
HI,
 Ive been trying to take example code from a post and work with it in my org, I've done all the step correctly I believe?  but I am getting an error: The Id in the error is belongs to the opportunity record. It happens when i click my custom button. 

If there is another way to recreate a configuration I would be interested in getting that information as well. 

Visualforce Error 
Id value 00618000007xXxxX is not valid for the QuoteRequest__c standard controller

The link to the post :
https://www.verticalcoder.com/2012/05/04/a-poor-mans-product-configurator/

my custom obejct 
Yushin_Product__c takes the place of the CustomProduct__c object in the example 

My Code:
<apex:page standardController="QuoteRequest__c" extensions="BL_QuoteRequestExtension">
  <apex:form >
    <apex:pageBlock >
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!Cancel}"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="Custom Product" collapsible="false">
        <apex:outputField value="{!QuoteRequest__c.Yushin_Product__c}"/>
      </apex:pageBlockSection>
      <apex:pageBlockSection columns="1" title="Options" collapsible="false">
        <apex:repeat value="{!$ObjectType.QuoteRequest__c.FieldSets.Group1}" var="f" >
          <apex:inputfield value="{!QuoteRequest__c[f]}" rendered="{!CustomProduct.Equipment_Type__c == 'Group1'}"/>
        </apex:repeat>
        <apex:repeat value="{!$ObjectType.QuoteRequest__c.FieldSets.Group2}" var="f" >
          <apex:inputfield value="{!QuoteRequest__c[f]}" rendered="{!CustomProduct.Equipment_Type__c == 'Group2'}"/>
        </apex:repeat>
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>











 
public with sharing class BL_QuoteRequestExtension {
    
  public Yushin_Product__c CustomProduct {get; set;}
  private final QuoteRequest__c opps;
 
  public BL_QuoteRequestExtension(ApexPages.StandardController controller) {
    this.opps = (QuoteRequest__c)controller.getRecord();
    try {
      CustomProduct = [select id, Equipment_Type__c from Yushin_Product__c where id=
                       :ApexPages.currentPage().getParameters().get('Yushin_Product__c')];
    } catch(Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Error Getting Product Info'));
    }
    if (CustomProduct != null)
    
      this.opps.Yushin_Product__c = CustomProduct.Id;
  }
}





 
I am trying to deploy a trigger and a test class to my production org and I'm recieving a couple of errors. Below is the error lesssage I recieved while using Eclipse to deploy them.
Run Failures:
  TestAfterPOLogUpdateTest.myUnitTest System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TriggerNewYushinProd: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: 012180000004huPAAQ: [RecordTypeId]

Although the issue is probalby something simple to fixe I've tried several different changes with no success. I have the Trigger and the Apex test class below. If anyone could help me with this issue I would really appreciate it.

Test Class:
@isTest
private class TestAfterPOLogUpdateTest {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        
        test.startTest();

      Opportunity opp = new Opportunity( Name ='Bob Inc.',polgid__c ='a4C39000000QFFiEAO', AccountId ='0017000000NAEsZ',StageName='Quoting',Who_is_quoting__c='Inside Sales', Type='EOAT', LeadSource ='NPE 2018', Describe_what_you_need_quoted__c='I need this test to work', Product_Type__c='Robot',   CloseDate=System.today() );
          
          insert opp;
          
          opp.polgid__c ='a4C39000000QFFiEAO';
          opp.OwnerId ='0053900000614sS';
          opp.Who_is_quoting__c='Inside Sales';
          opp.Product_Type__c='Conveyor';
          
          update opp;
      
      
      Yushin_Product__c yus = new Yushin_Product__c ();
          yus.Account__c ='0017000000NAEsZ';
          yus.Opportunity__c='0063900000sutn9';
          yus.PO_Log__c='a4C39000000QFKO';
          yus.Equipment_Type__c= 'A-Axis';
          yus.Model__c='';
          yus.Product_Detail_Report__c = 'EOAT-SM';
          yus.Discharge_Direction__c ='Clamp Traverse';
       	  
          insert yus;
          
          
          yus.Equipment_Type__c = 'Servo Trav 600 and under';
          yus.Model__c='RCII-100S-11-8.5';
          yus.Product__c = 'RCII-100S-11-8.5';
          yus.Price__c =45080;
          yus.IMM_Mfr__c = 'Toshiba';
          yus.Status__c ='Sold';
          yus.Booked_Date__c = Date.newInstance(2016, 12, 9);
          yus.PO_Log__c='a4C39000000QFKO';
          yus.Discharge_Direction__c ='Clamp Traverse';
          yus.Product_Detail_Report__c = 'EOAT-SM';
          yus.Discharge_Direction__c ='Clamp Traverse';
       	
          update yus;
          
          
          
          yus.Equipment_Type__c = 'Installation';
          yus.Product_Detail_Report__c = 'Installation';
          update yus;
          
          
          yus.Equipment_Type__c = 'EOAT';
          yus.Price__c = 499;
          yus.Model__c='';
          update yus;
           
          
          yus.Equipment_Type__c = 'Safety Guarding';
          yus.Product_Detail_Report__c = 'AUTO-SM';
          update yus;
           
          yus.Equipment_Type__c = 'Conveyor';
          update yus;
           
          yus.Equipment_Type__c = 'Servo Trav over 600';
          update yus;
           
          yus.Equipment_Type__c = 'Adapter Plate';
          update yus;
           
          yus.Equipment_Type__c = 'A-Axis';
          update yus;
          
          yus.Equipment_Type__c = 'B-Axis';
          update yus;
           
          yus.Equipment_Type__c = 'Freight';
          update yus;
           
          yus.Equipment_Type__c = 'Degating Station';
          update yus;
           
          yus.Equipment_Type__c = 'Installation';
          update yus;
           
          yus.Equipment_Type__c = 'Hybrid';
          update yus;
           
          yus.Equipment_Type__c = 'Software';
          update yus;
           
          yus.Equipment_Type__c = 'Servo Traverse Super Large 1300 and greater';
          update yus;
           
          yus.Equipment_Type__c = 'Spacer';
          update yus;
           
          yus.Equipment_Type__c = 'Stanchion';
          update yus;
          
          yus.Equipment_Type__c = 'Robot';
          update yus;
           
          yus.Equipment_Type__c = 'System - SMALL';
          update yus;
           
          yus.Equipment_Type__c = 'Collaborative robot';
          update yus;
           
          yus.Equipment_Type__c = 'Side-entry (horz)';
          update yus;
           
          yus.Equipment_Type__c = 'Side-entry (Vert)';
          update yus;
           
          yus.Equipment_Type__c = 'Parts';
          update yus;
           


      PO_Log__c pol = new PO_Log__c( Customer__c='0017000000NAEsZ',Opportunity__c='0063900000sutn9',Yushin_Product__c='a0639000020MH67', Order_Type__c='EOAT' );
      insert pol;
      
          pol.Opportunity__c ='0063900000sutn9';
          pol.PO__c = '12345';
          pol.Sales_Order_Number__c = '12453';
          pol.Order_Type__c = 'Robot';
          pol.AddPLogOpps__c = true;
          pol.Notes__c= 'text';
          pol.Order_Configuration__c = 'ATC';
          pol.Sales_Order_Number__c = '189345';
          pol.AddPLogOpps__c = true;
      
          update pol;
          
          

      

      test.stopTest();
    }
}


Trigger:
trigger TriggerNewYushinProd on Opportunity ( after insert, after update) {
    
    List<Yushin_Product__c> yus = new List<Yushin_Product__c>();
    List<Yushin_Product__c> yusToDelete = new List<Yushin_Product__c>();
    
    Map<Id, List<Yushin_Product__c>> existingYusMap = new Map<Id, List<Yushin_Product__c>>();
    
    for(Yushin_Product__c yu :[SELECT Id, Opportunity__c, Account__c, Equipment_Type__c from Yushin_Product__c where Opportunity__c IN :Trigger.newMap.keyset()]){
        List<Yushin_Product__c> yushinProducts = existingYusMap.get(yu.Opportunity__c);
        if (yushinProducts == null) {
            yushinProducts = new List<Yushin_Product__c>();
        }
        yushinProducts.add(yu);
        existingYusMap.put(yu.Opportunity__c, yushinProducts);
    }
    
    
    
    for(Opportunity o : Trigger.new)  {
        if (Trigger.IsInsert || Trigger.oldMap.get(o.Id).Product_Type__c == null) {
            if(o.Product_Type__c != null && o.Product_Type__c.contains('Robot'))               
            {                
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='Robot'; 
                y.RecordTypeId='012180000004huP';               
                yus.add(y);
            }
            
            if(o.Product_Type__c != null && o.Product_Type__c.contains( 'EOAT'))                
            {
                
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='EOAT';
                y.RecordTypeId='012180000004huU';               
                yus.add(y);
            }
            
            if(o.Product_Type__c != null && o.Product_Type__c.contains('Conveyor'))               
            {                
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='Conveyor';
                y.RecordTypeId='012180000004huZ';
                yus.add(y);
            }
            
            if(o.Product_Type__c != null && o.Product_Type__c.contains('Other'))               
            {                
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='Other';
                yus.add(y);
            }
        }
        else if (Trigger.IsUpdate && Trigger.oldMap.get(o.Id).Product_Type__c != null) {
            if(o.Product_Type__c != null && o.Product_Type__c.contains('Robot') && !Trigger.oldMap.get(o.Id).Product_Type__c.contains('Robot'))
            {
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='Robot';
                y.RecordTypeId='012180000004huP'; 
                yus.add(y);
            }
            
            if((o.Product_Type__c == null || !o.Product_Type__c.contains('Robot')) && Trigger.oldMap.get(o.Id).Product_Type__c.contains('Robot'))
            {
                List<Yushin_Product__c> yPs = existingYusMap.get(o.Id);
                for (Yushin_Product__c yP : yPs) {
                    if (yP.Equipment_Type__c == 'Robot') {
                        yusToDelete.add(yP);
                    }
                }
            }
            
            if(o.Product_Type__c != null && o.Product_Type__c.contains('EOAT') && !Trigger.oldMap.get(o.Id).Product_Type__c.contains('EOAT'))
            {                    
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='EOAT';  
                y.RecordTypeId='012180000004huU';                 
                yus.add(y);
            }
            
            if((o.Product_Type__c == null || !o.Product_Type__c.contains('EOAT')) && Trigger.oldMap.get(o.Id).Product_Type__c.contains('EOAT'))
            {
                List<Yushin_Product__c> yPs = existingYusMap.get(o.Id);
                for (Yushin_Product__c yP : yPs) {
                    if (yP.Equipment_Type__c == 'EOAT') {
                        yusToDelete.add(yP);
                    }
                }
            }
            
            if(o.Product_Type__c != null && o.Product_Type__c.contains('Conveyor') && !Trigger.oldMap.get(o.Id).Product_Type__c.contains('Conveyor'))                    
            {                    
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='Conveyor';
                y.RecordTypeId='012180000004huZ';
                yus.add(y);
            }
            
            if((o.Product_Type__c == null || !o.Product_Type__c.contains('Conveyor')) && Trigger.oldMap.get(o.Id).Product_Type__c.contains('Conveyor'))
            {
                List<Yushin_Product__c> yPs = existingYusMap.get(o.Id);
                for (Yushin_Product__c yP : yPs) {
                    if (yP.Equipment_Type__c == 'Conveyor') {
                        yusToDelete.add(yP);
                    }
                }
            }
            
            if(o.Product_Type__c != null && o.Product_Type__c.contains('Safety Guarding') && !Trigger.oldMap.get(o.Id).Product_Type__c.contains('Safety Guarding'))                    
            {                    
                Yushin_Product__c y=new Yushin_Product__c();
                y.Opportunity__c=o.Id;
                y.Account__c=o.AccountId; 
                y.Equipment_Type__c='Safety Guarding';
                y.RecordTypeId='012180000004hue';
                yus.add(y);
            }
            
            if((o.Product_Type__c == null || !o.Product_Type__c.contains('Safety Guarding')) && Trigger.oldMap.get(o.Id).Product_Type__c.contains('Safety Guarding'))
            {
                List<Yushin_Product__c> yPs = existingYusMap.get(o.Id);
                for (Yushin_Product__c yP : yPs) {
                    if (yP.Equipment_Type__c == 'Safety Guarding') {
                        yusToDelete.add(yP);
                    }
                }
            }
        }
    }  
 
    if(yus.size()>0)
        insert yus;
    if(yusToDelete.size()>0)
        database.delete(yusToDelete);
}