
import ABSL;
import AP.CRM.Global;
import AP.Common.GDT;
import AP.PC.SalesTerritoryMgmt.Global;
if( this.CreateOpportunity && this.OpportunityNumber.IsInitial() ) {
// Get the account and ee responsible of the SalesQuote
var accountID;
var eeResponsible;
foreach(var p in this.Party) {
if(p.RoleCode == "1001") {
accountID = p.PartyKey;
}
if(p.RoleCode == "39") {
eeResponsible = p.PartyKey;
}
}
// Get the primary contact as well
var primaryContact = this.Party.MainPartyContactParty.GetFirst();
// Create the opportunity
var oppNode:elementsof Opportunity;
oppNode.Name.content = this.Name.content;
oppNode.ProcessingTypeCode = "OPPT";
var opp = Opportunity.Create(oppNode);
var opportunity = opp;
this.OpportunityNumber = opp.ID.RemoveLeadingZeros().content;
foreach(var p in opp.Party) {
// Set the account party id
if(p.RoleCode == "31") {
p.PartyKey = accountID;
// When there is a primary contact, set it
if(primaryContact.IsSet() && !primaryContact.PartyKey.PartyID.IsInitial()){
var partyContact = p.PartyContactParty.Create();
partyContact.PartyKey.PartyID.content = primaryContact.PartyKey.PartyID.content;
}
}
// Set an employee responsible
if(p.RoleCode == "39") {
p.PartyKey = eeResponsible;
}
}
// Set the Business Area - Sales Org
opp.SalesAndServiceBusinessArea.SalesOrganisationID =
this.SalesAndServiceBusinessArea.SalesOrganisationID;
// Set the Business Area - Dist Channel
opp.SalesAndServiceBusinessArea.DistributionChannelCode =
this.SalesAndServiceBusinessArea.DistributionChannelCode;
// Set the Business Area - Division
opp.SalesAndServiceBusinessArea.DivisionCode =
this.SalesAndServiceBusinessArea.DivisionCode;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |