Answered by:
How to create a pre-Image for a subgrid fields in dynamic 365

Question
-
Hi all,
I am creating a plugin that changes the field of a subgrid(child record) in dynamic 365 using a plugin, Yes the plugin updates the field, but how do i create a preimage that returns the child records to its orevious state, when the checkbox that update the child record is unchecked to return the child record back to its previous state. My code is below:
if (approvalRequest.ukn_markallopcheckspass.Value) { QueryExpression appChkAns = new QueryExpression(ukn_approvalcheckanswer.EntityLogicalName); appChkAns.ColumnSet = new ColumnSet(true); appChkAns.Criteria.AddCondition("ukn_approvalrequestid", ConditionOperator.Equal, entity.Id); EntityCollection approvalCheckAnswer = service.RetrieveMultiple(appChkAns); foreach (var retrievedAppAns in approvalCheckAnswer.Entities) { if (retrievedAppAns != null) { int pass = 968200001; EntityReference sAppCheckQuest = retrievedAppAns.GetAttributeValue<EntityReference>("ukn_approvalcheckquestion"); ukn_approvalcheckquestion checkQuestion = (ukn_approvalcheckquestion)service.Retrieve(sAppCheckQuest.LogicalName, sAppCheckQuest.Id, new ColumnSet(new string[] { "ukn_name" })); if (checkQuestion != null && checkQuestion.ukn_name != null) { if (checkQuestion.ukn_name != "Any distribution netted off") { retrievedAppAns["ukn_decision"] = new OptionSetValue(pass); approvalRequest.ukn_markallopcheckspass = false; service.Update(retrievedAppAns); service.Update(approvalRequest); } else return; } } } }
Thanks
- Moved by Wendy ZangMicrosoft contingent staff Wednesday, July 31, 2019 5:46 AM
Tuesday, July 30, 2019 11:19 PM
Answers
-
Hello,
you could ask here:
https://community.dynamics.com/f
- Proposed as answer by Richard MuellerMVP, Banned Wednesday, July 31, 2019 12:34 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Monday, August 5, 2019 7:50 PM
Wednesday, July 31, 2019 5:55 AM
All replies
-
Hi OnyeBoss,
Thank you for posting here.
Since this thread is more related to Dynamic 365, C# forum may be not a good choice. Therefore,I will move it to Where is the Forum For…? forum to redirect it to the correct forum.
The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.
Best Regards,
Jack
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Wednesday, July 31, 2019 5:45 AM -
Hello,
you could ask here:
https://community.dynamics.com/f
- Proposed as answer by Richard MuellerMVP, Banned Wednesday, July 31, 2019 12:34 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Monday, August 5, 2019 7:50 PM
Wednesday, July 31, 2019 5:55 AM