on 2020 May 29 2:29 PM
Hi all,
I want to create a business rule in FSM that sends all attachments from the activity and the corresponding expense via email to the responsible of the activity triggered by a certain workflow-step.
I achieve everything in the BR except that dynamically all (multiple!) attachments get attached to the email. So I tried to write a for-loop in javascript, but it unfortunately does not work. I just get one (the first) attachment attached to the email.
See details to the business rule:
Trigger: (see screenshot)
Action: Send Mail (see screenshot)
for Attachment ID I tried:
${var i; for (var i = 0; i < attachment.length; i++) {attachment[i].id;}}
for File Name:
${var i; for (var i = 0; i < attachment.length; i++)
{attachment[i].fileName;}}_${technician.firstName}_${technician.lastName}__${serviceAssignmentStatus.createDateTime}_${serviceCall.code}.${var
i; for (var i = 0; i < attachment.length; i++)
{attachment[i].type;}}
The validation check is successful but if I execute the business rule, just 1 attachment is attached (see screenshot below) and no matter if I insert multiple attachment placeholder with the same code or with other starting points for i (always i=0 or i=1,2,3...) or just one placeholder.
Any ideas? This shoud be possible or isn't it?
Thanks so much & best regards
Deborah
Hi Deborah, regarding your question in your comment below my answer above, which is related to copying of attachments: Meanwhile there is a specific way for attachments, how you could copy an attachment to another object.
It should work like shown in the example below:
First read the attachment dto via Data API within action ‘FSM Webhook’ and
afterwards use another action ‘FSM Webhook’ to copy the attachment to another object,
which is specified in the body.
An important little thing is to parse the lastChanged attribute of the attachment, like done in the URL of the second action ‘FSM Webhook’, which is needed to have the right value of the date converted in the right format.
Best Regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello christian.hauck ,
thanks for your feedback! Really appreciated.
I tried to test the API Request first in Postman before I get it up and running via FSM BR.
I did not find the FSM API Package on SAP API Hub. The documentation in the help portal does not described it in detail. Unfortunaltey no example or explainations for the POST request on attachment API.
https://help.sap.com/docs/SAP_FIELD_SERVICE_MANAGEMENT/fsm_data_api/attachment-api.html?locale=en-US
If I try to do the copy action (as in your screenshot), I get the error "CA-27". See screenshot.
What do I need to change?
The last changed timestamp of the attachment I am trying to copy is from 31th August 2020. But I am trying to create a new attachment, so I dont really understand the conflict...
Best regards, Deborah
Hey Deborah,
I've already implemented the BusinessRule as Christian showed and it works for me.
But I've had the same problem as you. Unfortunately I'm not sure anymore what the problem was because it was already a while ago. I think it could be an authentification error. If I validate my BR the "user=..." isn't actually an the UUID of the User it is the id shown for users in the admin portal (user=${user.id}).
If you implement this into a business Rule I could help and compare it with my Rule if this would help you.
Greetings
Yanik
Hi all,
my issue was that I tried to send to current timestamp as lastChanged with the POST request.
I thought this timestamp will be set in the update on the database.
This understanding is wrong. If you perform the update you have to send the lastChanged unix timestamp of the last change on the attachment. Then it works!
A bit strange, I think... But, now it works. I could copy the attachment via API request from Business Partner to Activity.
Thanks a lot for your help!
Greetings, Deborah
User | Count |
---|---|
7 | |
6 | |
2 | |
2 | |
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.