To get Attachment details by using java script in d365

In Dynamics 365 CRM, To retrieve the attachments field name,type and Url by using javascript

Step 1: 
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];

 





Open entity modal popup in D365 CRM.

Now we can open Entity record as a popup. Here is the piece of code and it is supported only for opening records in the system. Try below.

Xrm.Navigation.navigateTo({
        pageType: "entityrecord",
        entityName: "contact",
        formType: 2, // Only Edit Mode is supported now. 
        formId: " ",
        entityId: " "
    }, {
        target: 2,
        position: 1,
        width: 700,
        height: 600
    });

Insert, update, delete, and order global option set options

How to Modify value of optionset by code C#?



DeleteOptionValueRequest deleteOptionValueRequest =
    new DeleteOptionValueRequest
{
    OptionSetName = _globalOptionSetName,
    Value = _insertedOptionValue
};

// Execute the request. svc.Execute(deleteOptionValueRequest);



Another method

UpdateOptionValueRequest updateOptionValueRequest =
    new UpdateOptionValueRequest
    {
        OptionSetName = _globalOptionSetName,
        // Update the second option value.
        Value = optionList[1].Value.Value,
        Label = new Label("Updated Option 1", _languageCode)
    };

_serviceProxy.Execute(updateOptionValueRequest);