Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Time Entries - msdyn_entrystatus

$
0
0

Dear all, 

I am new with plugins, but I should write a plugin to automatically approve Time Entry line after is submitted. So after timesheet line is submitted, status should be Approved. 

(OOB -> after is submited, msdyn_entrystatus status is Submited and the line can be seen in Approvals)

I wrote a plugin to change status in Approvals (msdyn_recordstage). It works , but in Time Entries, line status (msdyn_entrystatus ) stays  'Submitted'. It should be changed to 'Approved'.

What can I do to have the same result like I pressed 'Approve' in Approvals if OOB is used?

Thanks. 

This is my code till now:

var fetchEntity = service.Retrieve("bookableresource", ((EntityReference)entity["msdyn_submittedby"]).Id, new ColumnSet("userid"));

Entity approval = new Entity("msdyn_projectapproval");
approval.Id = entity.Id;
approval["msdyn_approvedby"] = new EntityReference("bookableresource", ((EntityReference)fetchEntity["userid"]).Id);
approval["msdyn_approvedon"] = DateTime.UtcNow;
service.Update(approval);

OrganizationRequest organizationRequest = new OrganizationRequest("msdyn_ApprovalStatusApprove");
organizationRequest["Target"] = new EntityReference("msdyn_projectapproval", entity.Id);
service.Execute(organizationRequest);

Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images