c# - How to override the default terms update from converting Opportunity to Sales Order -


i have added custom fields terms , ship via in opportunity , when pass value sales order. replaced default terms & ship via.

the following code using pass value opportunity sales order

public virtual ienumerable createsalesorder(pxadapter adapter) {      pxgraph.instancecreated.addhandler<soorderentry>((graph) =>     {         graph.rowinserted.addhandler<soorder>((cache, args) =>         {             var soorder = (soorder)args.row;             var soorderext = pxcache<soorder>.getextension<soorderextnv>(soorder);              foreach (cropportunity opportunity in adapter.get())             {                 oppertunityextn extopprow = pxcache<cropportunity>.getextension<oppertunityextn>(opportunity);                 soorderext.usropportunityid = opportunity.opportunityid;                 soorderext.usrcustomercontact = opportunity.contactid;                 soorderext.usrisembroidery = extopprow.usrisembroidery;                 soorderext.usrispromo = extopprow.usrispromo;                 soorderext.usrisblank = extopprow.usrisblank;                 soorderext.usrisservice = extopprow.usrisservice;                 soorderext.usrisdigital = extopprow.usrisdigital;                 soorderext.usrissample = extopprow.usrissample;                 soorderext.usrisscreenprint = extopprow.usrisscreenprint;                 soorderext.usrisrushjob = extopprow.usrisrushjob;                 soorderext.usrharddate = extopprow.usrharddate;                 soorderext.usrisinhandsdate = extopprow.usrisinhandsdate;                 soorderext.usreventdate = extopprow.usreventdate;                 soorderext.usreventdescription = extopprow.usreventdescription;                 soorderext.usrshipdate = extopprow.usrshipdate;                 soorderext.usrholduntil = extopprow.usrholduntil;                 soorderext.usrexactquantityneeded = extopprow.usrexactquantityneeded;                 soorderext.usrisnewcustomer = extopprow.usrisnewcustomer;                 soorderext.usrbatchship = extopprow.usrbatchship;                 soorderext.usrinternalref = extopprow.usrinternalref;                 soorder.shipvia = extopprow.usrshipvia;                 soorder.termsid = extopprow.usrterms;                 soorder.freightamt = extopprow.usrfreightestimate;              }         });         graph.rowpersisting.addhandler<soorder>((cache, args) =>             {                 var soorder = (soorder)args.row;                 foreach (cropportunity opportunity in adapter.get())                 {                     oppertunityextn extopprow = pxcache<cropportunity>.getextension<oppertunityextn>(opportunity);                     soorder.termsid = extopprow.usrterms;                 }              });     });     return base.createsalesorder.press(adapter); } 

termsid replaced after soorder row inserted. refer below code of opportunitymaint.docreatesalesorder. that’s why replaced value set @ customer’s level.

enter image description here

you should implement logic below. , use similar approach user fields well.

public class opportunitymaintpxext : pxgraphextension<opportunitymaint> {     public override void initialize()     {         pxgraph.instancecreated.addhandler<soorderentry>((graph) =>         {             graph.rowupdating.addhandler<soorder>((sender, e) =>             {                 soorder sodata = e.newrow soorder;                 if (sodata != null)                 {                     if (sender.getstatus(sodata) == pxentrystatus.inserted)                     {                         cropportunity opdata = base.opportunity.current;                         cropportunitypxext opdataext = pxcache<cropportunity>.getextension<cropportunitypxext>(opdata);                          sodata.termsid = opdataext.usrtermsid;                         sodata.shipvia = opdataext.usrshipvia;                     }                 }             });         });     } } 

Comments