hi,
I have 3 entity,but i have to automate 4 fields in 1 entity through plugin,but after execution its showing the below error:
this is my C# code:
if (context.Depth <= 1)
{
if (EntitySample != null)
{
Origin = EntitySample.FormattedValues["cim_origin"].ToString();
Destination = EntitySample.FormattedValues["cim_destination"];
ProductType = EntitySample1.FormattedValues["cim_producttype"].ToString();
ExpresionSC.ColumnSet = new ColumnSet(true);
EntityCollection colection = service.RetrieveMultiple(ExpresionSC);
ExpresionTC.ColumnSet = new ColumnSet(true);
EntityCollection colection1 = service.RetrieveMultiple(ExpresionTC);
if (colection != null && colection1 !=null)
{
//try
// {
foreach (Entity En in colection.Entities)
{
string OriginSC = En.FormattedValues["cim_origin"];
string DestinationSC = En.FormattedValues["cim_destinations"];
foreach (Entity En1 in colection1.Entities)
{
string ProductTypeTC = En1.FormattedValues["cim_typesofproducts"].ToString();
if (Origin == OriginSC && Destination == DestinationSC && ProductType == ProductTypeTC)
{
string duration = En.GetAttributeValue<string>("cim_transportdurations");
EntitySample["cim_shipmentduration"] = duration;
decimal cost = En.GetAttributeValue<Money>("cim_shipmentcost").Value;
EntitySample["cim_shipmentcost"] = new Money(cost);
DateTime date = EntitySample.GetAttributeValue<DateTime>("cim_startdate");
DateTime dt = date.AddDays(Convert.ToDouble(duration));
EntitySample["cim_estimatearrivaltime"] = dt;
Duration = En1.GetAttributeValue<string>("cim_duration");
EntitySample1["cim_testingdurtion"] =int.Parse(Duration);
service.Update(EntitySample);
service.Update(EntitySample1);
}
}
and the eror is:Invalid Argument
and the downloaded errordetails is:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Incorrect type of attribute value System.Int32Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220989</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Incorrect type of attribute value System.Int32</Message>
<Timestamp>2014-07-22T04:40:20.8594715Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
[Automation4ShipmentcostReq: Automation4ShipmentcostReq.Class1]
[18e3fa35-0211-e411-aa35-d89d67644f08: Automation4ShipmentcostReq.Class1: Update of cim_labbooking]
</TraceText>
</OrganizationServiceFault>
plz solve it as soon as possible, its very very urgent,plz solve it quickly