web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin code after Decompile

(0) ShareShare
ReportReport
Posted on by 458

Hi there All.
Thank you for your Help till now !
As you know I have Decompiled plugin as I asked Here and This, I have some problem with the code.
I have solved some of them, But some other exists.
Here is the problem :

    public new QuoteProduct CreatePreImageInstance()
    {
        QuoteProduct result = null;
        if (context.PluginExecutionContext.PreEntityImages.Contains(EntityResource.QuoteProduct) &&
            context.PluginExecutionContext.PreEntityImages().get_Item(EntityResource.QuoteProduct) != null)
        {
            Entity val = context.PluginExecutionContext.get_PreEntityImages().get_Item(EntityResource.QuoteProduct);
            result = val.ToEntity<QuoteProduct>();
        }
        return result;
    }

I changed this to :

    public new QuoteProduct CreatePreImageInstance()
    {
        QuoteProduct result = null;
        if (context.PluginExecutionContext.PreEntityImages.Contains(EntityResource.QuoteProduct) &&
            context.PluginExecutionContext.PreEntityImages.Values.FirstOrDefault(x=>x.LogicalName==EntityResource.QuoteProduct) != null)
        {
            Entity val = context.PluginExecutionContext.PreEntityImages.get_Item(EntityResource.QuoteProduct);

            result = val.ToEntity<QuoteProduct>();
        }
        return result;
    }


The problem is this line, Did I do the right thing in changing :

            context.PluginExecutionContext.PreEntityImages().get_Item(EntityResource.QuoteProduct) != null)


to :

 context.PluginExecutionContext.PreEntityImages.Values.FirstOrDefault(x=>x.LogicalName==EntityResource.QuoteProduct) != null)


?

The value EntityResource.QuoteProduct in .resx file is : quotedetail.

I guess I have done the right thing.

Also please help me on this :

public class DetailEntityHelper
{
	public Entity MergeEntity(Entity currentEntity, Entity preImageEntity)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		AttributeCollection attributes = currentEntity.Attributes;
		AttributeCollection attributes2 = preImageEntity.Attributes;
		Entity val = new Entity(currentEntity.LogicalName);
		foreach (KeyValuePair<string, object> item in attributes2)
		{
			if (attributes.Keys.Contains(item.Key))
			{
				val.get_Attributes().set_Item(item.Key, attributes.get_Item(item.Key));
			}
			else
			{
				val.get_Attributes().set_Item(item.Key, attributes2.get_Item(item.Key));
			}
		}
		foreach (KeyValuePair<string, object> item2 in attributes)
		{
			if (!val.Contains(item2.Key))
			{
				val.Attributes.Add(item2.Key, item2.Value);
			}
		}
		return val;
	}


on the line :

				val.get_Attributes().set_Item(item.Key, attributes.get_Item(item.Key));


I know I should use Add instead of set_Item,
But the second parameter (attributes.get_Item(item.key) is my problem.

Any help will Appreciate

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    If you appreciate other's help close previous threads using "Did this answer your question" section. Otherwise I'll merge this thread with ancestors you mentioned.

  • Albert_ Profile Picture
    458 on at

    I just did sir.

    ;-)

    Thank you for mentioning.

  • Albert_ Profile Picture
    458 on at

    I did in this way and hope it works !

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Albert,

    If your plugin is working fine after implementing images then it should be fine. When we register plugins on update message, we do not get all the field values in the plugin context, we then use plugin images to get the data of the target entity to perform business logic. That article is one of the best to understand images however if you are looking for some basics then you can refer this one as well: crmbook.powerobjects.com/.../plug-in-images-pre-vs-post

    Hope this helps.

  • Verified answer
    Albert_ Profile Picture
    458 on at

    Hi there.

    Thank you for your help.

    I finally did that by this thread.
    If you use ILSpy , And decompile all .dll files that are require and necessary and then decompile the actual dll file, it will extract just complete !

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans