Note: For all enhancements, the details of the namespace and deployment unit can be found in the Repository Explorer (as shown in the attached screenshot).
Note: This enhancement has a TYPE of "Multiple Use". That means the enhancement can be implemented for multiple business objects.
In this scenario, I will be implementing a single enhancement for 2 different business objects.
/*
Add your SAP Business ByDesign scripting language implementation for:
Enhancement Option: ExitForGettingWorkflowAttachment
Operation: GET_EXT_ATTACHMENT
Script file signature
----------------------------
Parameter: InputData of type InputStructureWorkflowsGetPdiAttachment
Returns: OutputStructureforWorkflowGetAttachment
Note:
- To use code completion, press CTRL+J.
*/
import AP.Workflow.Global;
import AP.Common.GDT;
import DocumentServices.Global as DS;
import AP.CRM.Global;
import ABSL;
var result : OutputStructureforWorkflowGetAttachment;
var lv_attachmentname : OutputStructureforWorkflowGetAttachment.AttachmentName;
var lv_attachmentContent : OutputStructureforWorkflowGetAttachment.AttachmentContent;
if (!InputData.TriggerBOUUID.IsInitial())
{
if (InputData.TriggerBOESRName.Name == "BusinessPartner")
{
var query = DocumentFacade.QueryByElements;
var resultData;
// 2. Selection
var selectionParams = query.CreateSelectionParams();
selectionParams.Add(query.Name, "I", "EQ", "Contact.docx");
// Result
resultData = query.Execute(selectionParams);
if (resultData.Count() > 0)
{
foreach (var iterator in resultData)
{
lv_attachmentname = iterator.Name;
if (iterator.ToDocument.IsSet())
{
var ToDocument = iterator.ToDocument;
if (ToDocument.CurrentVersion.IsSet())
{
var CurrentVersion = ToDocument.CurrentVersion.VersionFileVariant;
if (CurrentVersion.Count() > 0)
{
foreach (var iterator2 in CurrentVersion)
{
if (!iterator2.FileContentURI.IsInitial())
{
if (iterator2.VersionFileVariantContent.IsSet())
{
var VersionFileVariantContent = iterator2.VersionFileVariantContent;
lv_attachmentContent.content = VersionFileVariantContent.BinaryObject.content;
result.AttachmentName.Add(lv_attachmentname);
result.AttachmentContent.Add(lv_attachmentContent);
}
}
}
}
}
}
}
}
}
else if (InputData.TriggerBOESRName.Name == "Lead")
{
var query = DocumentFacade.QueryByElements;
var resultData;
// 2. Selection
var selectionParams = query.CreateSelectionParams();
selectionParams.Add(query.Name, "I", "EQ", "Lead.xlsx");
// Result
resultData = query.Execute(selectionParams);
if (resultData.Count() > 0)
{
foreach (var iterator in resultData)
{
lv_attachmentname = iterator.Name;
if (iterator.ToDocument.IsSet())
{
var ToDocument = iterator.ToDocument;
if (ToDocument.CurrentVersion.IsSet())
{
var CurrentVersion = ToDocument.CurrentVersion.VersionFileVariant;
if (CurrentVersion.Count() > 0)
{
foreach (var iterator2 in CurrentVersion)
{
if (!iterator2.FileContentURI.IsInitial())
{
if (iterator2.VersionFileVariantContent.IsSet())
{
var VersionFileVariantContent = iterator2.VersionFileVariantContent;
lv_attachmentContent.content = VersionFileVariantContent.BinaryObject.content;
result.AttachmentName.Add(lv_attachmentname);
result.AttachmentContent.Add(lv_attachmentContent);
}
}
}
}
}
}
}
}
}
}
return result;
Some Important Points:
Here I have implemented a single BADI (ExitForGettingWorkflowAttachment ) running for multiple business objects.
You can also implement the same BADI (ExitForGettingWorkflowAttachment ) again for a different business object and write your own logic.
If multiple implementations are done for the same business object, all will be executed for the workflow rule scheduled for that particular instance of a business object.
For example, if 2 workflow rules are implemented for a single business object (suppose : ticket), Both workflow rules are executed after meeting the necessary conditions and having the Add Attachment check box checked. Both implementations will be executed and fetch the attachments and add them to the e-mail.
This is kind of a flaw in the implementation as we cannot control which implementation to trigger, particularly for a workflow rule.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |