Error on Update RRS feed

  • Question

  • Hi All,

    I have a problem in my code. please help me.

    DynamicEntity CaseEntity = RetreiveDynamicEntity("incident", Caseid);
            CrmFloat Feeblance, Netbalnce, Paidamount;
            Feeblance.Value = ((CrmFloat)(CaseEntity.Properties["new_totalamount"])).Value;
            Netbalnce.Value = ((CrmFloat)(CaseEntity.Properties["new_netbalance"])).Value;
            Paidamount.Value = ((CrmFloat)(CaseEntity.Properties["new_paidamount"])).Value;
            DynamicEntity FeeEntity = RetreiveDynamicEntity("new_fee", FeeGuid);
            ActionAmount.Value = ((CrmFloat)(FeeEntity.Properties["new_actionamount"])).Value;
            Feeblance.Value = Feeblance.Value - ActionAmount.Value;
            Netbalnce.Value = Feeblance.Value - Paidamount.Value;
            CaseEntity.Properties.Add(new CrmFloatProperty("new_totalamount",Feeblance));
            CaseEntity.Properties.Add(new CrmFloatProperty("new_netbalance",Netbalnce));
            // Create the update target.
            TargetUpdateDynamic updateDynamic = new TargetUpdateDynamic();
            // Set the properties of the target.
            updateDynamic.Entity = CaseEntity;
            //  Create the update request object.
            UpdateRequest update = new UpdateRequest();
            //  Set request properties.
            update.Target = updateDynamic;
            //  Execute the request.
            UpdateResponse updated = (UpdateResponse)service.Execute(update);

    It gives me 3 errors:
    "Use of unassigned local  variable 'Feebalance'."
    "Use of unassigned local  variable 'Netbalance'."
    "Use of unassigned local  variable 'PaidAmount'."


    Tuesday, December 28, 2010 11:59 AM


All replies

  • CrmFloat Feeblance, Netbalnce, Paidamount;
    Change to

    CrmFloat Feeblance =Null;

    CrmFloat  Netbalnce=Null;

    CrmFloat Paidamount=Null;


    Mahain : My Dynamics CRM Blog
    Tuesday, December 28, 2010 12:09 PM
  • Hello.


    You should change lines

    CrmFloat Feeblance, Netbalnce, Paidamount;


    CrmFloat Feeblance = new CrmFloat();
    CrmFloat  Netbalnce = new CrmFloat();
    CrmFloat Paidamount = new CrmFloat();

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Tuesday, December 28, 2010 12:39 PM
  • Hi With this it gives me this message at the execution.

    Object reference not set to an instance of an object.



    Tuesday, December 28, 2010 3:13 PM
  • Please validate spelling of the variables used in your code; it doesn't matter if they're spelled wrong, so long as they're always spelled wrong.  The code you pasted adheres to this, but the errors you posted do not--which makes me wonder which is correct, the errors or the code.

    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Tuesday, December 28, 2010 7:40 PM
  • Hi Andriy, Thanks a lot your code worked. Regards, Shivam
    Tuesday, December 28, 2010 8:10 PM