Step 1:
function GetName(executioncontext)
function GetName(executioncontext)
{
var formcontext=executioncontext.getFormComtect();
var file= formcontext.getAttribute("new_attachment").getValue();
var view=file.fileUrl;
var attachment=file.fileName;
var attachments=file.mimtype;
var attach=attachments.split('/')[0];
if( attach== "image")
{
formcontext.getAttribute("new_attachmenttype").setValue("Image");
}
if( attach== "application")
{
formcontext.getAttribute("new_attachmenttype").setValue("Document");
}
if( attach== "video")
{
formcontext.getAttribute("new_attachmenttype").setValue("Video");
}
if( attach== "text")
{
formcontext.getAttribute("new_attachmenttype").setValue("Document");
}
}
Step 2: To get name and file type.
var attachments=file.mimtype;
We can get the file type.
Step 3: To get Url
var view=file.fileUrl;
Step 4: To split the file type. I have used split.
var file= formcontext.getAttribute("new_attachment").getValue();
var attachments=file.mimtype;
var attach=attachments.split('/')[0];