on 06-29-2022 4:40 AM
Hi,
I had done the attachment in MDK but i am unable to get type type i means unable to what type of file is attached. I need to help to find the file type and file size.
{
"_Type": "Control.Type.FormCell.Attachment",
"_Name": "Attachment19",
"IsVisible": true,
"OnValueChange": "/RFI_UPDATESet/uploadAttachment.js",
"AttachmentActionType": [
"TakePhoto",
"SelectFile"
],
"AttachmentTitle": "Media",
"AllowedFileTypes": [
"jpg",
"png",
"gif",
"pdf",
"word",
"file",
"doc",
"csv"
],
"AttachmentAddTitle": "Camera"
},
{
"Value": "{filename}",
"_Type": "Control.Type.FormCell.SimpleProperty",
"_Name": "filename",
"IsEditable": true,
"IsVisible": true
},
Hello Vinay
When you get the value (e.g. via getValue method or the getClientData().AddedAttachment) of your attachment control in a rule, it'll return an array of attachments. Each item in the array is of type IAttachment. There's a property called contentType that allow you to check what type it is.
e.g.
// If you are calling this rule from the FormCell Attachment control's OnValueChange
// then the context will be the FormCell Attachment control itself. so
// you can just call: let attachedFiles = context.getClientData().AddedAttachments;
// Otherwise find the control first in the current page first
// let myAttachementCtrl = context.evaluateTargetPathForAPI("#Control:MyAttachementCtrl");
// let attachedFiles = myAttachmentCtrl.getClientData().AddedAttachments
export default function uploadAttachment(context) {
// Get the added attachments
let attachedFiles = context.getClientData().AddedAttachments;
if (attachedFiles && attachedFiles.length > 0) {
var len = attachedFiles.length;
for (var i=0; i < len; i++) {
var attachment = attachedFiles[I];
// Do something with the content type
// console.log(attachment.contentType);
}
}
}
Regards
Ming
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinay, you can pass them via Action Binding, please refer to following documentation about Action Binding and Result.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.