Dear All,
I have written a sample action which is not working somehow;
Please check the below references and help me out to solve this.
Entity;

Custom Action Code:
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Newtonsoft.Json;
using System;
using System.Activities;
using System.Collections.Generic;
using System.IO;
using System.Net;
namespace DataClone
{
public class CarRentalAction : CodeActivity
{
[Input("Currency Code")]
public InArgument<string> CurrencyCode { get; set; }
[Input("Total Price")]
public InArgument<decimal> TotalPrice { get; set; }
[Output("Converted Price")]
public OutArgument<decimal> TotalPriceinEURO { get; set; }
public class Currency
{
public Dictionary<string, decimal> rates;
[JsonProperty("base")]
public string Base { get; set; }
public string date;
}
protected override void Execute(CodeActivityContext context)
{
var workflowContext = context.GetExtension<IWorkflowContext>();
var serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
var orgService = serviceFactory.CreateOrganizationService(workflowContext.UserId);
TotalPriceinEURO.Set(context, Convert.ToDecimal(TotalPrice.ToString()) * 100);
}
}
}
Action:

JavaScript Which Trigger the action on Save of entity to set TotalPriceinEURO field:
function CallmyAction(executionContext) {
debugger;
var formContext = executionContext.getFormContext();
var Id = Xrm.Page.data.entity.getId().replace('{', '').replace('}', '');
var CurrencyCode = formContext.getAttribute("my_name").getValue();
var TotalPrice= formContext.getAttribute("my_totalprice").getValue();
var parameters = {};
var entity = {};
entity.id = Id;
entity.entityType = "my_customentity1";
parameters.entity = entity;
parameters.CurrencyCode = CurrencyCode;
parameters.TotalPrice = TotalPrice;
var my_myActionRequest = {
entity: parameters.entity,
CurrencyCode: parameters.CurrencyCode,
TotalPrice: parameters.TotalPrice,
getMetadata: function() {
return {
boundParameter: "entity",
parameterTypes: {
"entity": {
"typeName": "mscrm.my_customentity1",
"structuralProperty": 5
},
"CurrencyCode": {
"typeName": "Edm.String",
"structuralProperty": 1
},
"TotalPrice": {
"typeName": "Edm.Decimal",
"structuralProperty": 1
}
},
operationType: 0,
operationName: "my_myAction"
};
}
};
Xrm.WebApi.online.execute(my_myActionRequest).then(
function success(result) {
if (result.ok) {
var results = JSON.parse(result.responseText);
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
}