i have triggered plugin on create and update of opportunity, it works fine when i debug but the created records are not showing on the subgrid of opportunity.
i have triggered plugin on create and update of opportunity, it works fine when i debug but the created records are not showing on the subgrid of opportunity.
thank you for your ans. this works well.
i have plugin for update but don't know how to give id to update. my code is
if (retrievedEntity.Entities.Count > 0)
{
for (int i = 1; i < weeknumber.Length; i++)
{
Entity newentity = new Entity("test_resourcefulfilment");
entity.id=????
newentity["test_weeknumber"] = weeknumber[i].ToString();
newentity["test_hours"] = hours[i];
service.Update(newentity);
}
}
Its the name I have assumed you have used to add a lookup field on the test_resourcefulfilment entity that references the opportunity entity where you want these records to appear.
what is the type of attribute "test_opporutinity"?
Yes you do need to add an entityreference to the opportunity as otherwise the system doesn't know what those newly created records relate to.
new_entity["test_opportunity"]=new EntityReference(entity.logicalname, entity.Id);
should do it.
I want to split the date into week wise and stores the hours weekwise , so i have one entity which stores the week wise data of opportunity using plugin.
I want to show in the subgrid which is related to only that opportunity , but it is showing all records
this is my code, can I use entity refrence to map the fields because it is not showing related records in subgrid?
for (int i = 1; i < weeknumber.Length; i++)
{
Entity newentity = new Entity("test_resourcefulfilment");
newentity["test_name"] = entity.Attributes["name"];
newentity["test_weeknumber"] = weeknumber[i].ToString();
newentity["test_hours"] = hours[i];
service.Create(newentity);
}
It's worth emphasising that the front end interfaces of Dynamics 365 are separate to the back end systems and the front end refreshes have become far more specific / granular over the years - the front end will now only refresh grids it is told it needs to refresh.
Having said the above, I assume your plugin is creating a child record(s) that need to appear on the subgrid once the record is saved. If that is the case (and assuming that the plugin is running synchronously) you will need to trigger a refresh of the subgrid when the records completes saving for the new record to be visible.
Now the code to get the gridcontext and to refresh the grid is (I'm assuming you are using version 9 and above):
function doSomething(executionContext) { var formContext = executionContext.getFormContext(); // get the form Context var gridContext = formContext.getControl("Contacts"); // get the grid context gridContext.refresh(); // Perform operations on the subgrid }
You will need to trigger than sometime after the record is saved (probably be putting it in a timeout function with a 5-10 second delay within an onsave javascript event).
Hi,
It seems that your plugin doesn't finish its job. You could go to solution explorer to check the Process Sessions' status. If it is not succeed you could use Plugin Profile to debug your plugin step by step. You could refer to the following thread linkage for more debugging process details.
https://community.dynamics.com/365/sales/f/762/t/285612
Related video : https://www.youtube.com/watch?v=zTM2l-J6opk
Johnnyg
Hi Srishti!!
Can you give us more details about your question? What kind of records are created? What view are you using in subgrid?
Regards!!
André Arnaud de Cal...
292,489
Super User 2025 Season 1
Martin Dráb
231,305
Most Valuable Professional
nmaenpaa
101,156