-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
7Questions
-
9Replies
Insert nested records using rest class with existing ID of parent
I need to be the one who input the Id of Account to `Subscription_Order__c` and the Product__c id to `OrderProduct__c`
This is my sample code. I was able to do this with newly created Account but I need to use an id of an existing account.
I already tried this
`global static string doPost(id AccountID){`
and then
`wso.subscriptionOrder.Account__c = AccountId ;`
But it's throwing an `Unexpected parameter encountered during deserialization` error.
Your help is much appreaciated
@restResource(urlMapping='/buyproduct/*') global with sharing class buyProduct{ private class OrderWrapper{ Account account; List<subscriptionOrderWrapper> so; } private class subscriptionOrderWrapper{ Subscription_Order__c subscriptionOrder; List<OrderProduct__c> orderProductList; } @HttpPost global static string doPost(){ OrderWrapper container = (OrderWrapper)System.JSON.deserialize( RestContext.request.requestBody.tostring(), OrderWrapper.class); System.debug('#####1' + container); Account acc = container.account; insert acc; System.debug('#####2' + acc); List<Subscription_Order__c> soInsert = new List<Subscription_Order__c>(); for(subscriptionOrderWrapper wso : container.so){ //wso.subscriptionOrder.Account__c = acc.id; //Account__c = Inputted id of existing account id request body soInsert.add(wso.subscriptionOrder); } insert soInsert; System.debug('#####3' + soInsert); list<OrderProduct__c> opInsert = new List<OrderProduct__c>(); for(subscriptionOrderWrapper wso : container.so){ for(OrderProduct__c orderProduct : wso.orderProductList){ orderProduct.Subscription_Order__c = wso.subscriptionOrder.Id; //subcription_Product__c = Inputted id of an existing product__c in request Body opInsert.add(orderProduct); } } insert opInsert; system.debug('#####4' + opInsert); return acc.Id; } }
This is my request body when I am having the `Unexpected parameter encountered during deserialization` error
{ "so": [{ "subscriptionOrder":{ "Account" : 0016F00001sZtG0QAK } }] }
- Juan Miguel Francia
- January 25, 2017
- Like
- 0
Someone help me with Test Class for Deep Clone
Can someone help me create a test class for Deep Cloning? I used field sets btw and Kinda stuck with this one for days. Any help will be pretty much appreaciated thank you.
This is my vf page for reference
<apex:page standardController="Opportunity" extensions="LPGVSPOpportunityCloneControllerExt" action="{!DeepClone}" > <apex:form > <!--apex:commandButton action="{!DeepClone}" value="Clone SAP Opportunity"/--> </apex:form> </apex:page>
and this is my extension for cloning.
public class LPGVSPOpportunityCloneControllerExt { public Opportunity opp { get; set; } public Opportunity newopp {get; set;} public String opportunityID {get; set;} public List<Opportunity> newOpportunity{get;set;} public List<Opportunity> newOpportunityCloned; public List<Opportunity> oldOpportunity; public LPGVSPOpportunityCloneControllerExt (ApexPages.StandardController ctrl) { newopp = (Opportunity)ctrl.getRecord(); opportunityID =(String)ctrl.getRecord().get('Id'); String query = 'SELECT '; for(Schema.FieldSetMember f : this.getFields()) { query += f.getFieldPath() + ', '; } query += 'Id FROM Opportunity where Id=: opportunityID '; opp = (Opportunity)Database.query(query); } public List<Schema.FieldSetMember> getFields() { return SObjectType.Opportunity.FieldSets.LPG_SAP_Opportunity_Clone_Fields.getFields(); } public PageReference DeepClone(){ Opportunity temp = opp.clone(false, True, false, false); temp.Name += '-SPR'; temp.RecordTypeID = Opportunity.SObjectType.getDescribe().getRecordTypeInfosByName().get('LPG EU - Vendor SPR').getRecordTypeId(); insert temp; for(OpportunityLineItem oli : [Select Id, OpportunityID, pricebookentryId, unitPrice , Quantity from OpportunityLineItem where OpportunityID =: opp.ID]){ OpportunityLineItem oliNew = oli.clone(false,True,false,false); oliNew.OpportunityId = temp.Id; insert oliNew; } PageReference NewOpportunity = new PageReference('/' + temp.id); NewOpportunity.setRedirect(true); return NewOpportunity; } }
Thank you so much
- Juan Miguel Francia
- October 28, 2016
- Like
- 0
Javascript in Visualforce, Using <apex:inputfield>
So basically I need to create a javascript
<apex:page Controller="editLineItemSPRCOMM" cache="false" tabstyle="Opportunity" action="{!initAfter}"> <script type="text/javascript"> function buttonValidate(){ return confirm("Do you want to save this"); </script> <apex:form id="form1" > <apex:pageBlock title="Line Item Calculator" id="aa"> <apex:pageMessages id="pmsg"/> <apex:pageBlockButtons > <apex:commandButton styleClass="butt1" value="Save and Return" action="{!saveLineItems}" onclick="buttonValidate()"/> <!-- <apex:commandButton value="Refresh" action="{!refreshLineItems}"/> --> </apex:pageBlockButtons> <!-- Line Calculator for EMEA users --> <!--apex:column headerValue="Recommended End User Discount %"--> <apex:column headerValue="Rec. End User Disc %" id="ac"> <apex:inputField value="{!myVar.item.Rec_EndUser_Disc__c}" id="myNumber"> <apex:actionSupport event="onchange" action="{!calculateRecEndUserPrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg" id="aaa"/> </apex:inputField> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
validation where in It will check my <apex:inputfield>. If it has the value of 0 it will throw a confirm with the field that is 0 and will ask the user if he wants to continue to save. Can someone help me please, been stuck with this one for days.
This is my VF Page It might be short because I tend to just put the important part.
- Juan Miguel Francia
- October 28, 2016
- Like
- 0
Javascript in Visualforce
I need to create a javascript in my vf page where in if one of the values of my inputfield is 0 once I save it, it will alert a confirmation button message if I want to continue or not. My problem is I don't know how to call my apex:inputfield to the javascript function.
1.) My main concern is I want to know how I can call my apex:inputfield to the javascript function
2.) and also. How can I cancel an action once the javascript function is triggered. As you can see with my code below. I have two checkboxes that locks a column. Now I have a java script function where in if two checkboxes are checked it will throw an alert where in it will tell the user that only 1 checkbox should be clicked, it runs but it still continue to check the checkbox.
This is my code for educational purposes.
<apex:page Controller="editLineItemSPRCOMM" cache="false" tabstyle="Opportunity" action="{!initAfter}"> <style type="text/css"> input{width:75px;} .workingText{ color: #D8000C; background-color: #FFBABA; font-style: italic; font-family:"serif"; } .bPageBlock .requiredInput .requiredBlock{ background-color: #FFF; } .butt1{ width:110px; } } </style> <apex:form > <apex:pageBlock title="Line Item Calculator"> <apex:pageMessages id="pmsg"/> <apex:pageBlockButtons > <apex:commandButton styleClass="butt1" value="Save and Return" action="{!saveLineItems}"/> <!-- <apex:commandButton value="Refresh" action="{!refreshLineItems}"/> --> </apex:pageBlockButtons> <apex:outputPanel styleClass="workingText"> <apex:actionStatus startText=" Processing... " stopText="" id="counterStatus" onStart="document.body.style.cursor = 'wait';return true;" onStop="document.body.style.cursor = 'default';return true;"/> </apex:outputPanel> <apex:outputText id="panel1" value="{!message}"/> <!--Check box--> <apex:actionFunction name="method1" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg" /> Lock Rec End User Price<apex:inputCheckbox html-data-single="" value="{!readOnly}" id="cb1" onclick="Check()" onchange="check(method1)"> </apex:inputCheckbox> <!--Check box--> <!--Check box--> <apex:actionFunction name="method2" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg" /> Lock Dist SPR Disc %<apex:inputCheckbox html-data-single="" value="{!readOnlyB}" id="cb2" onclick="Check()" onchange="check(method1)"> </apex:inputCheckbox> <!--Check box--> <apex:pageBlockTable value="{!Objects}" var="myVar" id="table" rendered="{!!showEMEA}"> <apex:column headerValue="Product">{!myVar.product.Name}</apex:column> <apex:column headerValue="Product Code">{!myVar.product.ProductCode}</apex:column> <apex:column headerValue="Quantity"> <apex:inputField value="{!myVar.item.Quantity}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="List Price">{!myVar.item.ListPrice}</apex:column> <apex:column headerValue="Sales Discount (%)"> <apex:inputField value="{!myVar.item.Discount_Percent_Off__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="Dealer Discount Price"> <apex:inputField value="{!myVar.item.Dealer_Discount_Price__c}"> <apex:actionSupport event="onchange" action="{!calculateDiscount}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="SPR Discount"> <apex:inputField value="{!myVar.item.SPR_Discount__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="SPR Price"> <apex:inputField value="{!myVar.item.SPR_Price__c}"> <apex:actionSupport event="onchange" action="{!calculateDiscountSPR}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!-- Removed 4/28 <apex:column headerValue="Guaranteed Margin "> <apex:inputField value="{!myVar.item.Margin__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus"/> </apex:inputField> </apex:column> --> <!-- Removed 8/15 in order to fix issue where GM would be updated by updating Sales Price <apex:column headerValue="Sales Price" id="Price"> <apex:inputField value="{!myVar.item.UnitPrice}"> <apex:actionSupport event="onchange" action="{!calculateMargin}" status="counterStatus" rerender="table,panel1,counterStatus"/> </apex:inputField> </apex:column> --> <!-- <apex:column headerValue="Discount"> <apex:outputText >{!myVar.item.Discount}</apex:outputText> </apex:column> <apex:column headerValue="Unit Price"> <apex:outputText >{!myVar.item.UnitPrice}</apex:outputText> </apex:column> <apex:column headerValue="Total Price"> <apex:outputText >{!myVar.item.TotalPrice}</apex:outputText> </apex:column> --> <apex:column headerValue="Total Price"> <apex:outputText >{!myVar.b}</apex:outputText> </apex:column> <!-- Added on 04-15-2014 : Vinay --> <apex:column headerValue="Commission"> <apex:inputField value="{!myVar.item.Commission__c}"> <apex:actionSupport event="onchange" action="{!calculateCommissionPercentage}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!-- Added on 04-15-2014 : Vinay --> <apex:column headerValue="Commission %"> <apex:inputField value="{!myVar.item.Commission_Percent__c}"> <apex:actionSupport event="onchange" action="{!calculateCommission}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> </apex:pageBlockTable> <!-- Line Calculator for EMEA users --> <apex:pageBlockTable value="{!Objects}" var="myVar" id="table2" rendered="{!showEMEA}"> <apex:column headerValue="Product">{!myVar.product.Name}</apex:column> <apex:column headerValue="Product Code">{!myVar.product.ProductCode}</apex:column> <!--apex:column headerValue="Recommended End User Discount %"--> <apex:column headerValue="Rec. End User Disc %"> <apex:inputField value="{!myVar.item.Rec_EndUser_Disc__c}"> <apex:actionSupport event="onchange" action="{!calculateRecEndUserPrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Recommended End User Price"--> <apex:column headerValue="Rec. End User Price"> <apex:inputField value="{!myVar.item.Recommended_end_user_price__c}" rendered="{!NOT(readOnly)}"> <apex:actionSupport event="onchange" action="{!calculateRecEndUserDiscount}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> <apex:outputField value="{!myVar.item.Recommended_end_user_price__c}" rendered="{!readOnly}"/> </apex:column> <!--apex:column headerValue="Distributor Std Discount %"--> <apex:column headerValue="Dist Standard Disc %"> <apex:inputField value="{!myVar.item.Discount_Percent_Off__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Distributor Standard Price"--> <apex:column headerValue="Dist Std Price"> <apex:inputField value="{!myVar.item.Dealer_Discount_Price__c}"> <apex:actionSupport event="onchange" action="{!calculateDiscount}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Distributor SPR Discount %"--> <apex:column headerValue="Dist SPR Disc %"> <apex:inputField value="{!myVar.item.SPR_Discount__c}" rendered="{!NOT(readOnlyB)}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> <apex:outputField value="{!myVar.item.SPR_Discount__c}" rendered="{!readOnlyB}"/> </apex:column> <!--apex:column headerValue="Distributor SPR Price"--> <apex:column headerValue="Dist SPR Price"> <apex:inputField value="{!myVar.item.SPR_Price__c}" html-placeholder="0.00000" > <apex:actionSupport event="onchange" action="{!calculateDiscountSPR}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg,totalDiscount"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Distributor SPR Margin"--> <apex:column headerValue="Dist SPR Margin"> <apex:inputField value="{!myVar.item.Distributor_SPR_Margin__c}"> <apex:actionSupport event="onchange" action="{!ChangeMargin}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="Quantity"> <apex:inputField value="{!myVar.item.Quantity}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="List Price">{!myVar.item.ListPrice}</apex:column> <apex:column headerValue="Total Price"> <apex:outputText >{!myVar.b}</apex:outputText> </apex:column> <apex:column headerValue="Total Discount %"> <apex:outputText id="totalDiscount">{!myVar.Item.TotalDiscount__c}</apex:outputText> </apex:column> </apex:pageBlockTable> <script> function check(fn) { if (document.querySelectorAll('[data-single]:checked').length===2) { alert('Please choose only one.'); } else { fn(); } } </script> </apex:pageBlock> </apex:form> </apex:page>
- Juan Miguel Francia
- October 19, 2016
- Like
- 0
Trigger Accessing Records from a lookup of another Object
This is the only part I need so that I can finish my before Insert/before Update Trigger. Thank you in advance. Hoping you can answer my question.
- Juan Miguel Francia
- September 22, 2016
- Like
- 0
- Juan Miguel Francia
- September 20, 2016
- Like
- 0
Need Help to finish my 1st afterInsert Trigger Handler
1st.) Get the newly created MatterID
2nd.) Query newly created OpportunityAccount for where OpportunityId = Matter__c.Project_Name__c (OpptyId)
3rd.) Get List based on Query.
4th.) Make List listOfMatterAccounts.
5th.) insert the data to a for loop.
Can you please help me finish my code. I created a something but I feel like it is not the right way to do it.
This is the original pseudo code given to me.
Add Related Vendor records to the Opportunity. Create New Matter from Opportunity [New Matter]... Make selections on Matter edit page.... Save. PB or afterInsert Trigger Handler gets Opportunity Id from Save event. ----Start Code Here---- Get new id for Matter.... <new matter id> Query newly created OpportunityAccount for where OpportunityId = Matter__c.Project_Name__c (OpptyId) Get List<Account> based on Query. Make List<MatterAccount__c> listOfMatterAccounts. for(Account a : listofOpportunityAccounts) { MatterAccount__c ma = new MatterAccount(); ma.matterid = <new matter id> ma.accountid = a.id ma.opportunityid = ma.Matter__c.Project_Name__c } listofMatterAccounts.insert(ma);
This is my code so far.
public static void RelatedVendor(){ //get new MatterID ID RecordID; List<Matter__c> listMatter = new List<Matter__c>(); List<OpportunityAccount__c> opporAccList = [Select id, opportunity__c from OpportunityAccount__c where id in : Trigger.new]; List<MatterAccount__c> mattAccList = new List<MatterAccount__c>(); for(Matter__c m :(List<Matter__c>)Trigger.new){ RecordID = m.Id; for(OpportunityAccount__c oa :opporAccList){ oa.Opportunity__c = m.Project_Name__c; opporAccList.add(oa); } for(Account a : opporAccList){ MatterAccount__c ma = new MatterAccount__c(); ma.Matter__c = RecordID; ma.Vendor__c = a.ID; ma.Opportunity__c = m.Project_Name__c; mattAccList.add(ma); } insert mattAccList; } }
- Juan Miguel Francia
- September 19, 2016
- Like
- 0
Insert nested records using rest class with existing ID of parent
I need to be the one who input the Id of Account to `Subscription_Order__c` and the Product__c id to `OrderProduct__c`
This is my sample code. I was able to do this with newly created Account but I need to use an id of an existing account.
I already tried this
`global static string doPost(id AccountID){`
and then
`wso.subscriptionOrder.Account__c = AccountId ;`
But it's throwing an `Unexpected parameter encountered during deserialization` error.
Your help is much appreaciated
@restResource(urlMapping='/buyproduct/*') global with sharing class buyProduct{ private class OrderWrapper{ Account account; List<subscriptionOrderWrapper> so; } private class subscriptionOrderWrapper{ Subscription_Order__c subscriptionOrder; List<OrderProduct__c> orderProductList; } @HttpPost global static string doPost(){ OrderWrapper container = (OrderWrapper)System.JSON.deserialize( RestContext.request.requestBody.tostring(), OrderWrapper.class); System.debug('#####1' + container); Account acc = container.account; insert acc; System.debug('#####2' + acc); List<Subscription_Order__c> soInsert = new List<Subscription_Order__c>(); for(subscriptionOrderWrapper wso : container.so){ //wso.subscriptionOrder.Account__c = acc.id; //Account__c = Inputted id of existing account id request body soInsert.add(wso.subscriptionOrder); } insert soInsert; System.debug('#####3' + soInsert); list<OrderProduct__c> opInsert = new List<OrderProduct__c>(); for(subscriptionOrderWrapper wso : container.so){ for(OrderProduct__c orderProduct : wso.orderProductList){ orderProduct.Subscription_Order__c = wso.subscriptionOrder.Id; //subcription_Product__c = Inputted id of an existing product__c in request Body opInsert.add(orderProduct); } } insert opInsert; system.debug('#####4' + opInsert); return acc.Id; } }
This is my request body when I am having the `Unexpected parameter encountered during deserialization` error
{ "so": [{ "subscriptionOrder":{ "Account" : 0016F00001sZtG0QAK } }] }
- Juan Miguel Francia
- January 25, 2017
- Like
- 0
Javascript in Visualforce, Using <apex:inputfield>
So basically I need to create a javascript
<apex:page Controller="editLineItemSPRCOMM" cache="false" tabstyle="Opportunity" action="{!initAfter}"> <script type="text/javascript"> function buttonValidate(){ return confirm("Do you want to save this"); </script> <apex:form id="form1" > <apex:pageBlock title="Line Item Calculator" id="aa"> <apex:pageMessages id="pmsg"/> <apex:pageBlockButtons > <apex:commandButton styleClass="butt1" value="Save and Return" action="{!saveLineItems}" onclick="buttonValidate()"/> <!-- <apex:commandButton value="Refresh" action="{!refreshLineItems}"/> --> </apex:pageBlockButtons> <!-- Line Calculator for EMEA users --> <!--apex:column headerValue="Recommended End User Discount %"--> <apex:column headerValue="Rec. End User Disc %" id="ac"> <apex:inputField value="{!myVar.item.Rec_EndUser_Disc__c}" id="myNumber"> <apex:actionSupport event="onchange" action="{!calculateRecEndUserPrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg" id="aaa"/> </apex:inputField> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
validation where in It will check my <apex:inputfield>. If it has the value of 0 it will throw a confirm with the field that is 0 and will ask the user if he wants to continue to save. Can someone help me please, been stuck with this one for days.
This is my VF Page It might be short because I tend to just put the important part.
- Juan Miguel Francia
- October 28, 2016
- Like
- 0
Javascript in Visualforce
I need to create a javascript in my vf page where in if one of the values of my inputfield is 0 once I save it, it will alert a confirmation button message if I want to continue or not. My problem is I don't know how to call my apex:inputfield to the javascript function.
1.) My main concern is I want to know how I can call my apex:inputfield to the javascript function
2.) and also. How can I cancel an action once the javascript function is triggered. As you can see with my code below. I have two checkboxes that locks a column. Now I have a java script function where in if two checkboxes are checked it will throw an alert where in it will tell the user that only 1 checkbox should be clicked, it runs but it still continue to check the checkbox.
This is my code for educational purposes.
<apex:page Controller="editLineItemSPRCOMM" cache="false" tabstyle="Opportunity" action="{!initAfter}"> <style type="text/css"> input{width:75px;} .workingText{ color: #D8000C; background-color: #FFBABA; font-style: italic; font-family:"serif"; } .bPageBlock .requiredInput .requiredBlock{ background-color: #FFF; } .butt1{ width:110px; } } </style> <apex:form > <apex:pageBlock title="Line Item Calculator"> <apex:pageMessages id="pmsg"/> <apex:pageBlockButtons > <apex:commandButton styleClass="butt1" value="Save and Return" action="{!saveLineItems}"/> <!-- <apex:commandButton value="Refresh" action="{!refreshLineItems}"/> --> </apex:pageBlockButtons> <apex:outputPanel styleClass="workingText"> <apex:actionStatus startText=" Processing... " stopText="" id="counterStatus" onStart="document.body.style.cursor = 'wait';return true;" onStop="document.body.style.cursor = 'default';return true;"/> </apex:outputPanel> <apex:outputText id="panel1" value="{!message}"/> <!--Check box--> <apex:actionFunction name="method1" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg" /> Lock Rec End User Price<apex:inputCheckbox html-data-single="" value="{!readOnly}" id="cb1" onclick="Check()" onchange="check(method1)"> </apex:inputCheckbox> <!--Check box--> <!--Check box--> <apex:actionFunction name="method2" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg" /> Lock Dist SPR Disc %<apex:inputCheckbox html-data-single="" value="{!readOnlyB}" id="cb2" onclick="Check()" onchange="check(method1)"> </apex:inputCheckbox> <!--Check box--> <apex:pageBlockTable value="{!Objects}" var="myVar" id="table" rendered="{!!showEMEA}"> <apex:column headerValue="Product">{!myVar.product.Name}</apex:column> <apex:column headerValue="Product Code">{!myVar.product.ProductCode}</apex:column> <apex:column headerValue="Quantity"> <apex:inputField value="{!myVar.item.Quantity}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="List Price">{!myVar.item.ListPrice}</apex:column> <apex:column headerValue="Sales Discount (%)"> <apex:inputField value="{!myVar.item.Discount_Percent_Off__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="Dealer Discount Price"> <apex:inputField value="{!myVar.item.Dealer_Discount_Price__c}"> <apex:actionSupport event="onchange" action="{!calculateDiscount}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="SPR Discount"> <apex:inputField value="{!myVar.item.SPR_Discount__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="SPR Price"> <apex:inputField value="{!myVar.item.SPR_Price__c}"> <apex:actionSupport event="onchange" action="{!calculateDiscountSPR}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!-- Removed 4/28 <apex:column headerValue="Guaranteed Margin "> <apex:inputField value="{!myVar.item.Margin__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table,panel1,counterStatus"/> </apex:inputField> </apex:column> --> <!-- Removed 8/15 in order to fix issue where GM would be updated by updating Sales Price <apex:column headerValue="Sales Price" id="Price"> <apex:inputField value="{!myVar.item.UnitPrice}"> <apex:actionSupport event="onchange" action="{!calculateMargin}" status="counterStatus" rerender="table,panel1,counterStatus"/> </apex:inputField> </apex:column> --> <!-- <apex:column headerValue="Discount"> <apex:outputText >{!myVar.item.Discount}</apex:outputText> </apex:column> <apex:column headerValue="Unit Price"> <apex:outputText >{!myVar.item.UnitPrice}</apex:outputText> </apex:column> <apex:column headerValue="Total Price"> <apex:outputText >{!myVar.item.TotalPrice}</apex:outputText> </apex:column> --> <apex:column headerValue="Total Price"> <apex:outputText >{!myVar.b}</apex:outputText> </apex:column> <!-- Added on 04-15-2014 : Vinay --> <apex:column headerValue="Commission"> <apex:inputField value="{!myVar.item.Commission__c}"> <apex:actionSupport event="onchange" action="{!calculateCommissionPercentage}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!-- Added on 04-15-2014 : Vinay --> <apex:column headerValue="Commission %"> <apex:inputField value="{!myVar.item.Commission_Percent__c}"> <apex:actionSupport event="onchange" action="{!calculateCommission}" status="counterStatus" rerender="table,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> </apex:pageBlockTable> <!-- Line Calculator for EMEA users --> <apex:pageBlockTable value="{!Objects}" var="myVar" id="table2" rendered="{!showEMEA}"> <apex:column headerValue="Product">{!myVar.product.Name}</apex:column> <apex:column headerValue="Product Code">{!myVar.product.ProductCode}</apex:column> <!--apex:column headerValue="Recommended End User Discount %"--> <apex:column headerValue="Rec. End User Disc %"> <apex:inputField value="{!myVar.item.Rec_EndUser_Disc__c}"> <apex:actionSupport event="onchange" action="{!calculateRecEndUserPrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Recommended End User Price"--> <apex:column headerValue="Rec. End User Price"> <apex:inputField value="{!myVar.item.Recommended_end_user_price__c}" rendered="{!NOT(readOnly)}"> <apex:actionSupport event="onchange" action="{!calculateRecEndUserDiscount}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> <apex:outputField value="{!myVar.item.Recommended_end_user_price__c}" rendered="{!readOnly}"/> </apex:column> <!--apex:column headerValue="Distributor Std Discount %"--> <apex:column headerValue="Dist Standard Disc %"> <apex:inputField value="{!myVar.item.Discount_Percent_Off__c}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Distributor Standard Price"--> <apex:column headerValue="Dist Std Price"> <apex:inputField value="{!myVar.item.Dealer_Discount_Price__c}"> <apex:actionSupport event="onchange" action="{!calculateDiscount}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Distributor SPR Discount %"--> <apex:column headerValue="Dist SPR Disc %"> <apex:inputField value="{!myVar.item.SPR_Discount__c}" rendered="{!NOT(readOnlyB)}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> <apex:outputField value="{!myVar.item.SPR_Discount__c}" rendered="{!readOnlyB}"/> </apex:column> <!--apex:column headerValue="Distributor SPR Price"--> <apex:column headerValue="Dist SPR Price"> <apex:inputField value="{!myVar.item.SPR_Price__c}" html-placeholder="0.00000" > <apex:actionSupport event="onchange" action="{!calculateDiscountSPR}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg,totalDiscount"/> </apex:inputField> </apex:column> <!--apex:column headerValue="Distributor SPR Margin"--> <apex:column headerValue="Dist SPR Margin"> <apex:inputField value="{!myVar.item.Distributor_SPR_Margin__c}"> <apex:actionSupport event="onchange" action="{!ChangeMargin}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="Quantity"> <apex:inputField value="{!myVar.item.Quantity}"> <apex:actionSupport event="onchange" action="{!calculatePrice}" status="counterStatus" rerender="table2,panel1,counterStatus,pmsg"/> </apex:inputField> </apex:column> <apex:column headerValue="List Price">{!myVar.item.ListPrice}</apex:column> <apex:column headerValue="Total Price"> <apex:outputText >{!myVar.b}</apex:outputText> </apex:column> <apex:column headerValue="Total Discount %"> <apex:outputText id="totalDiscount">{!myVar.Item.TotalDiscount__c}</apex:outputText> </apex:column> </apex:pageBlockTable> <script> function check(fn) { if (document.querySelectorAll('[data-single]:checked').length===2) { alert('Please choose only one.'); } else { fn(); } } </script> </apex:pageBlock> </apex:form> </apex:page>
- Juan Miguel Francia
- October 19, 2016
- Like
- 0
- Juan Miguel Francia
- September 20, 2016
- Like
- 0
Need Help to finish my 1st afterInsert Trigger Handler
1st.) Get the newly created MatterID
2nd.) Query newly created OpportunityAccount for where OpportunityId = Matter__c.Project_Name__c (OpptyId)
3rd.) Get List based on Query.
4th.) Make List listOfMatterAccounts.
5th.) insert the data to a for loop.
Can you please help me finish my code. I created a something but I feel like it is not the right way to do it.
This is the original pseudo code given to me.
Add Related Vendor records to the Opportunity. Create New Matter from Opportunity [New Matter]... Make selections on Matter edit page.... Save. PB or afterInsert Trigger Handler gets Opportunity Id from Save event. ----Start Code Here---- Get new id for Matter.... <new matter id> Query newly created OpportunityAccount for where OpportunityId = Matter__c.Project_Name__c (OpptyId) Get List<Account> based on Query. Make List<MatterAccount__c> listOfMatterAccounts. for(Account a : listofOpportunityAccounts) { MatterAccount__c ma = new MatterAccount(); ma.matterid = <new matter id> ma.accountid = a.id ma.opportunityid = ma.Matter__c.Project_Name__c } listofMatterAccounts.insert(ma);
This is my code so far.
public static void RelatedVendor(){ //get new MatterID ID RecordID; List<Matter__c> listMatter = new List<Matter__c>(); List<OpportunityAccount__c> opporAccList = [Select id, opportunity__c from OpportunityAccount__c where id in : Trigger.new]; List<MatterAccount__c> mattAccList = new List<MatterAccount__c>(); for(Matter__c m :(List<Matter__c>)Trigger.new){ RecordID = m.Id; for(OpportunityAccount__c oa :opporAccList){ oa.Opportunity__c = m.Project_Name__c; opporAccList.add(oa); } for(Account a : opporAccList){ MatterAccount__c ma = new MatterAccount__c(); ma.Matter__c = RecordID; ma.Vendor__c = a.ID; ma.Opportunity__c = m.Project_Name__c; mattAccList.add(ma); } insert mattAccList; } }
- Juan Miguel Francia
- September 19, 2016
- Like
- 0