on 10-16-2020 2:17 PM
Hi Experts.
I was required the following developing.
An agent creates a lead from a sales ticket, so when the lead change status as "win, lose or direct to distributor", its respective ticket must change the statuss to close.
My question is how is te best practice for this,
It must be in sap SDK or can be donde directyle in C4C. and How?
Hope you can give me a signal....
Regards.
Hi Luis,
Your Issue with the Status: Might be due to the fact that not all tickets can be closed immediately if they have been created.
Ty to set to Status of the Ticket if it is in Status "Open", at first to "In Process" and then to "Closed."
Concerning your issue with the BTDF:
this.BusinessTransactionDocumentReference.GetFirst().BusinessTransactionDocumentReference.ID.content;
as the node is 0..n, you need to use a loop and search for the correct entry.
var refs = this.BusinessTransactionDocumentReference
var ticketRef : Lead.BusinessTransactionDocumentReference;
foreach(var ref in refs) {
var refs = obj.BusinessTransactionDocumentReference;
var ticketRef : Lead.BusinessTransactionDocumentReference;
foreach(var ref in refs) {
if(ref.BusinessTransactionDocumentRelationshipRoleCode == "2") { //1 = Predecessor, 2 = Successor
if(ref.BusinessTransactionDocumentReference.TypeCode == "118") { //118 = Ticket
if(! ref.BusinessTransactionDocumentReference.ID.content.IsInitial()) {
ticketRef = ref;
break; //break because we have found the reference and quit from the loop
}
}
}
}
if(ticketRef.IsSet()) {
var ticket = ServiceRequest.Retrieve(ticketRef.ID.content.RemoveLeadingZeros());
if(ticket.IsSet()) {
var serviceTerms = ticket.ServiceTerms;
if(serviceTerms.IsSet()) {
serviceTerms.ServiceRequestUserLifeCycleStatusCode = "5"; //5 = Closed (I hope so)
}
}
}
}
If your script file is mass enabled (which should be the case if you just create the script file and not change any checkboxes in the Script File Creation dialogue) you need to wrap a loop around it.
foreach(var lead in this) {
var refs = lead.BusinessTransactionDocumentReference;
var ticketRef : Lead.BusinessTransactionDocumentReference;
foreach(var ref in refs) {
if(ref.BusinessTransactionDocumentRelationshipRoleCode == "2") { //1 = Predecessor, 2 = Successor
if(ref.BusinessTransactionDocumentReference.TypeCode == "118") { //118 = Ticket
if(! ref.BusinessTransactionDocumentReference.ID.content.IsInitial()) {
ticketRef = ref;
break; //break because we have found the reference and quit from the loop
}
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Dominik, it was awesome like a great explained tutorial.
thanks too much it really works and finally my code looks like this, I share cuz I think it can be useful for someone else...
in Event-BeforeSave
import ABSL;
import AP.CRM.Global;
if(this.Status.UserStatusCode == "04" || this.Status.UserStatusCode == "05" || this.Status.UserStatusCode == "Z1"){
var Leadrefs = this.BusinessTransactionDocumentReference;
var ticketRef : Lead.BusinessTransactionDocumentReference;
foreach(var ref in Leadrefs) {
foreach(ref in Leadrefs) {
if(ref.BusinessTransactionDocumentReference.TypeCode == "118") { //118 = Ticket
if(! ref.BusinessTransactionDocumentReference.ID.content.IsInitial()) {
ticketRef = ref;
break; //break because we have found the reference and quit from the loop
}
}
}
if(ticketRef.IsSet()) {
var ticket = ServiceRequest.Retrieve(ticketRef.BusinessTransactionDocumentReference.ID);
if(ticket.IsSet()) {
var serviceTerms = ticket.ServiceTerms;
if(serviceTerms.IsSet()) {
serviceTerms.ServiceRequestUserLifeCycleStatusCode = "6"; //6 = Closed
}
}
}
}
}
Thanks again
Regards.
Luis Angel
Hello Luis,
1) Create an XBO for the Lead BusinessObject. In Root.After-Before Safe to check if the Status of the Lead is being changed to "win, lose or direct to distributor";
2) if the condition is true, Query the Ticket by checking the business transaction document reference node from the Lead; RelationshipRoleCode 2 (Successor), TypeCode 118 (Ticket)
3) If you have found the ticket, set the ServiceRequestUserLifeCycleStatusCode (ServiceRequest.ServiceTerms) from the Ticket to Closed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dominik,
Thanks for answering, you helped me a lot!
I am having trouble closing the ticket,
Indetifier "ServiceTerms" does not exits.
What im doing wrong?
Also is have a little dout with step 2, i Have called first item in lead like
ticketID = this.BusinessTransactionDocumentReference.GetFirst().BusinessTransactionDocumentReference.ID.content;
and im thinking it could be a problem it there are more items there and take wrong one.
Thanks
Regards.
Hello,
Since tickets and leads are not directly linked from the standard SAP business process point of view, hence SAP doesn't offer any standard solution like workflow or configuration to manage such a scenario where upon Win/Lose of lead will close the ticket.
Therefore, you need to write a small action(ABSL script) in Lead XBO via SDK which will query the related Ticket and mark the ticket as close. This action can be configured as part of the workflow for "Leads" business object and can be triggered as action in step 3. Alternatively, you can also write the entire logic in BeforeSave event of Leads BO without any need to declaring a custom action, but better condion handling is needed there.
Thanks
Saurabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi luisangeln ,
I think steps/logic are very nicely mentioned by dominik.g in his answer below. Further in order to close the ticket you do not need to set any status code. You can simple use standard action close() as follow:( Let say service request instance to be closed is srvReqInst )
srvReqInst.close();
And this will mark the ticket as close. This way you can skip step 3 in Dominik solution below. However step 1 and 2 will still be valid.
It is an issue of case sensitivity. Instead of using "close()" you need to use "Close();" 🙂
srvReqInst.Close();
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.