Quantcast
Channel: SCN : Popular Discussions - SAP Cloud Applications Studio
Viewing all articles
Browse latest Browse all 1333

populate account owner with current user

$
0
0

Hello,

 

We need to populate the Account Owner with current user, I've written some code and put it in Customer-Root-Event-BeforeSave, but there are reports that it works incosistently - sometimes it does trigger sometimes it doesn't. Could you please look at the code and point on to where this inconsistency may come from?

 

import ABSL;
import AP.PC.IdentityManagement.Global;
var currentIdentityUUID = Context.GetCurrentIdentityUUID();
var currentIdentity = Identity.Retrieve(currentIdentityUUID);
var currentIdentityEmployee = Employee.Retrieve(currentIdentity.BusinessPartnerUUID);
var currentIdentityEmployeeID = currentIdentityEmployee.IdentificationEmployeeID.EmployeeID.content;
var customerCurrentEmployeeResponsible:elementsof Customer.CurrentEmployeeResponsible;

customerCurrentEmployeeResponsible.EmployeeID.content = currentIdentityEmployeeID;
customerCurrentEmployeeResponsible.PartyRoleCode = "142";

var currentAccountOwner = this.CurrentEmployeeResponsible.Where(n=>n.PartyRoleCode.Matches("142"));

if (currentAccountOwner.Count() == 0) {
          this.CurrentEmployeeResponsible.Create(customerCurrentEmployeeResponsible);
}

Best regards,

 

Danil


Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>