dynamics crm 2011 - How to access the organization from within a plugin? -
i'm reading ill-written code , brains shut down, due frustration, question easy one.
i'm in plugin , need create new instance of entity blobb. given have query expression done, how execute it? have go through creating organizationserviceproxy object or can use iserviceprovider instance sent execute method? i'm using context (i.e. ipluginexecutioncontext typed object) can't find service method execute query expression.
i think looking this. can use execute using localplugincontext.
public class orgplugin: plugin { public orgplugin() : base(typeof(orgplugin)) { base.registeredevents.add(new tuple<int, string, string, action<localplugincontext>>(20, "create", "account", new action<localplugincontext>(executeorgplugin))); } protected void executeorgplugin(localplugincontext localcontext) { blobb blobb = new blobb(); blobb["new_name"] = "abc"; // other attributes here localcontext.organizationservice.execute(blobb); } } edit
you can extract organizationservice localcontext.organizationservice
iorganizationservice service = localcontext.organizationservice;
Comments
Post a Comment