I’m having an issue when I’m trying to grab the GUID for a contract in CRM2011. First of all I have a workflow which creates an entity record, which than fires a plugin to renew a contract. It works fine when I’m setting the contract ID to a new GUID as seen below:
RenewContractRequest req = new RenewContractRequest();
req.IncludeCanceledLines = true;
req.ContractId = new Guid("1767AD4E-CAF4-E011-8D97-1CC1DEF1B5FF");
req.Status = 1;
RenewContractResponse resp = (RenewContractResponse)service.Execute(req);
However when I’m trying to do this:
Guid getContract_id = (Guid)((Entity)context.InputParameters["Target"])["contractid"];
RenewContractRequest req = new RenewContractRequest();
req.ContractId = getContract_id;
req.IncludeCanceledLines = true;
req.Status = 1;
RenewContractResponse resp = (RenewContractResponse)service.Execute(req);
I get an exception that the given key was not present in the dictionary, which I understand as, it hasn’t recognised the GUID I’m setting it to ? It might be something really stupid I’m doing, I hope someone can help me out here.
Hi guys thank you very much for your help.
I have figured it out myself, I have made use of Query Expressions to retrieve the Id (GUID) and the number of the specific contract. As I will have many contracts in the future I believe that was a better way of getting the Id.