Dynamics 365 Plugin Development Notes

Plugins Discussion

  • Post operation vs. pre operation.

  • Yesterday's class summary:

    • Understanding post and pre operation code is crucial.

    • Post operation is automatically saved.

    • Service start update can be done in two ways:

      • Create a new object.

      • Use source record info.

  • Creating New Objects with JSON

    • object create json service update json

    • prepaid json object

    • Example: creating an empty object and adding properties.

  • Source Recording

    • Using source recording can lead to infinite loops due to HID and depth concepts.

  • Implementation Options for Intent

    • Pre-operation line implementation

    • Post-operation line implementation (two ways)

      • Setting source record info.

      • Creating a new object.

  • Preload Test Intent

    • Requesting an additional if and an automatic set of operations to save and save data.

  • Pre Operation vs Post Operation

    • Prefer pre operation for simple tasks.

    • Use post operation for more complex tasks.

Current Issue

  • Calculation logic considers only updated data.

    • Currently in post operation, but should be in pre operation.

  • Reason for Considering only updated fields:

    • Values are only updated in the updated fields.

  • Solutions Discussed:

    • Creating a new object using JSON.

    • Using source recording info.

Understanding System Behavior

  • Focus on understanding system behavior regarding data updates.

  • Scenario 1: New Record Creation

    • New fields data are entered.

    • Object is created.

    • The system prepares JSON.

  • Scenario 2: Update

    • Data changes at the backend.

    • Source record info object is used.

    • System prepares an object with all schema names upon clicking 'save'.

  • Data Preparation

    • Data entered via the UI is used to create an object with all the schema names.

    • The system pumps the source record info into the backend.

  • Update Scenario Details

    • Backend includes source record info value.

    • Example: telemarkstelemarks are entered.

    • Query: Source record info contains telemarkstelemarks, so telemarkstelemarks get overridden.

    • If source record info does not contain second language marks, they default to zero.

  • Reason for Considering Only Updated Values (Recap):

    • In update scenarios, only updated properties are present in source recording info.

    • Other fields become zero if not updated.

Pre Image and Post Image Concept

  • Understanding pre image and post image is crucial.

  • Audit History Importance

    • Tracking recent changes.

    • Seeing old and new values.

  • Preimage

    • Represents the old value before the update.

  • Postimage

    • Represents the latest value after the update.

  • Example Scenario

    • Phone number update from 567890 to a new value.

    • Pre image gives the old value (567890).

    • Post image gives the latest value.

  • Data Retrieval

    • Plugin capability to take data from source record info, pre image, or post image.

  • Example: Telomox Update

    • Original telomox value: 88.

    • Value updated to 77.

  • Data Values

    • Source record info: 77 (latest value).

    • Preimage: 88 (old value).

    • Post image: 77 (updated value).

  • Other Subject Marks (English)

    • No updates: Source record info, pre image, and post image all show the same value.

  • Fixing Plugin Issues

    • Use post image to get the latest values instead of sourcing recording for updates.

  • Configuration Steps

    • Open plugin.

    • Right-click, register a new image.

    • Select 'post' image type.

    • Provide a name (e.g., updated data).

  • Selecting Attributes (Fields)

    • Choose only the required subject marks attributes.

  • Code Configuration

    • Instead of source record info, use the term post image.

    • Code example: postImageData=context.PostEntityImages[n¨ame]¨postImageData = context.PostEntityImages[\"name\"];

Considerations

  • Source recording info has limitations.

  • Post image provides more flexibility.

Plugin Registration Tool

  • Steps:

    • Open the tool.

    • Right-click, register new image.

    • Select pre or post based on requirements.

    • Enter a name and select calculation attributes (fields).

    • Use image data quality instead of source recording info in your code.

Debugging and Troubleshooting

  • Field Update Issue

    • Example: Second language marks update not reflecting.

    • Downloaded logs show 'key not present in dictionary'.

    • Target level issue.

  • Troubleshooting Steps

    • Check target level.

    • Verify object and data capture.

    • Ensure entity data type is correct.

  • Debugging Methods

    • Trace logs: unsol dot log, unsol dot trace log for issue identification.

    • Debugging process.

  • Trace Logs

    • Easy to understand for fast issue resolution.

    • Example: total secured marks as an integer pass, not a string pass.

Coding Practices

  • Clean code before updating (clean chess, build chess, update chess).

  • Expected vs. Actual

    • Validate expected behavior against actual behavior.

  • Download Log

    • Check the download log to identify the exact line impacted.

  • Tracing Service Default Plugin Structure

    • Tracing service, trace locks, IAC.

    • Write whatever you want in the lines.

  • Clean JSON is Compulsory

    • Enables the latest updated code.

  • Trace Logs in the System

    • System captures warranty when trace logs are enabled.

  • How to Enable Trace Logs in System Settings

    • Go to system settings.

    • Advanced settings.

    • Open and enable logging to plug in trace locks (customizations).

    • By default, it's offline.

    • Turn on and save.

  • Show Details and Download Log

    • Check from advanced find, plug in trace logs.

    • Filter by created until the last one ever.

  • Trace Log Details

    • Plugin name, entity, execution details, start time.

    • Line-by-line execution tracking.

  • Identifying Issues

    • Based on message, you can't issue object preparation.

    • Capture the message to identify issues.

  • Plugin Exceptions

    • Check plugin trace log to identify issues.

  • Operational Considerations

    • Wait for a few seconds or one minute to get the plugin trace lock.

  • Trace Logs - Success vs Failure

    • Trace logs enabled only for exceptions.

    • Helpful to capture data storage issues.

  • Create and Update Code Commonality

    • Same code can trigger for create and update.

    • Differentiate using context dot messageName.

  • Create and Update Scenarios

    • Create: Fail; Update: Success.

  • Differentiating Create and Update Inside Logic

    • Using context.messageName to differentiate between create and update events.

    • Example: if (context.messageName.ToLower() == "create")

  • Code Alignment

    • Use Control + K + D for automatic code alignment.

  • Variables Declaration

    • Declare variables at the top for accessibility.

  • Code Structure

    • Create and update logic within the same code file but differentiated via conditional statements.

  • Common Code

    • Lines of code are common for both create and update.

    • Example: Taking data from source record info vs. post image.

  • Code Repetition

    • Identify common lines in both create and update.

Efficient Code Implementation

  • If Else structure

  • Variable Declaration

    • Declare at a global level for both create and update access.

  • Image Concept

    • Pre operation, post operation differentiate image key vs image data accessed.

      • Pre: Data Post Data.

    • Preimage & Postimage render different pipeline stages.

  • Code Validation

  • Testing

Classic UI vs. Cognitive Power Apps

  • Requirement: Preimage, post image, and the importance of audit history.

  • Limitations of Out-of-the-Box Audit History

    • Limited reports and advanced find capabilities.

    • Azure user login 30 data update not available.

  • Custom Entity Auditing

    • Client wants a custom entity for auditing, including:

      • SSE marks list.

      • Marks results.

  • Custom Entity Details

    • Entity related records with parent-child relationship.

  • Fields in Custom Entity

    • Lookup to SSE student

    • New Telugu marks, new English marks

    • Old Telugu marks, old English marks

    • Name field (primary field)

  • Requirement Details

    • When a new record is created or data is updated in marks (English or Telugu), capture old and new values.

  • Create Event Scenario

    • Example: New Telugu marks 99, new English Marks 99

  • Differentiate Plugin Trigger

    • Use context.messageName (create or update).

  • Capture Record Create Time Record

  • PopulateLookup current record populate.

  • If fields are updated capture the old and new values.

  • Requirements: System has to take care of me.

  • The code automate chess now.

  • Old value create new record create old value new value.

  • Instructions for Plug in Implement

    • Triggering entity: SSE mark list.

    • Trigger events: Create and update.

  • CheckList to follow

  • First- Create JSON implement focus.

  • Entity Create Changes

  • Implement XML

  • Fields To Create

    • New English marks, old English marks etc.

    • User to log in data capture.

  • Action log in modified by owner field.

  • The details is required

  • Lookup, subgrid requirement.

Visual Studio Setup

  • Create new project.

  • Change the class name to meaningful name

  • Copy the plugin CS file and replace into the notepad

  • Copy and replace namespace and class name

  • Add the Microsoft Assembly.

Creating the record

  • Creating Syntax Same as update.

  • Automatic new entry on the creation

  • If the source entity and logic name is same can it be reused

  • Record has to be implemented in the audit record creation.

  • Audit record name has to be created in the partial.

Setup of parameters

  • Syntax of student data get for type paint.

  • Get and set syntax for Look of parameters from the field subgrid.

  • Lookup value has to has syntax format

  • Then student data type needs to be defined. Single line or text?

  • Can we add the sub grid?

  • Get method needs to work if any issue persists.

  • What is the event and field selection for new Telugumox?

  • Event automatic context start message that needs to be worried.

Setup of the get images to run the code

  • We have the system source recording pre- image and post image

  • Which way do we get the code pre + post and run entity image capture with syntax.

  • Two images pre actual and post actual needs to be done sepeartely.

  • Close everything in ten to fifteen minutes

  • The event needs to be chosen.

  • Once complete store the result in the post and get the fields created

  • Data type information required whether integer or decimal

  • If decimal or integer is not working then use get statement syntax

  • We can use this the lookup logical name for audit.

    • record store chest, colon, entity.

  • We can take from string store the chest.

    • Partial source entity can use student lookup id from code.

  • Project sign in settings

  • Build is success sign needs to be sign

Code needs to registers events right now

  • Entity needs to create to catch the code in the step.

  • Focus on the technology to understand requirements.

  • Salary and experience depends on knowledge.

    • Easy demand and understand the code very importantly.

    • Plugins for pre post needs to focus on this.

  • Interviews are important by focusing on the tasks.

Last Step Conclusion.

  • Pre and post loads needs to happen to update the new date with update entity.

  • After updating the trigger entity the system updates the post operation Json file.

  • No images needs to be run.

  • The images creates the fail events and the create code fail on the entity.

    • Code fail and success rates depend pre setup on the entities.

    • If conditional logic needs to setup create update or lower layer. So needs to create code setup from starting setup.