Dynamics CRM 2011 - How to relate two different entities - dynamics-crm-2011

I have two different custom entities. The first one (payment) I create manually using a form. When the payment is created it executes a plugin that will create one or more vouchers. The plugin creates the voucher without a problem. The problem is when I go to the payment and click on vouchers, I don't see the voucher I just created listed. If I go look at all the vouchers I can see the one I just created. There is a 1 to many relationship from payment to voucher. What do I need to do in my plugin for the entities to be related?
Thanks

Sounds like you just haven't setup the relationship back to the triggering payment when you create the voucher.
Given the 1:N relationship and since you're creating the voucher in the context of a payment plugin you can set the lookup on the voucher to the payment for which the plugin is currently executing (target).
new_voucher.new_paymentid = new EntityReference(...);
new_paymentid is the lookup attribute on voucher (obviously it'll be called something else in your case). For the EntityReference you'll need to define the EntityName and Id of the product, which you can read from the target.

Related

Is it possible to link the opportunity and project with a different constituent in NetSuite?

i am not able to populate the system field "Prject" on opportunity record if the project and opportunity records have a different constituent
I have created the project from opportunity, but by some reason the opportunity has not been linked with the created project. I tried to connect them(populate the project field on opportunity) using a script but get the error: Invalid job reference key for the entity . It seems that netsuite doesn't allow project to be linked with the opportunity with a different client. Is there a way to populate the program field "Project" on opportunity and link the record with each other without changing the constituent on the records?
You would have to create a new Custom body or column field that would allow you to select any Project (regardless of which constituent/institution it is attached to). From there make considerations for why you want the 2 linked, and note that NetSuite will not complete any automation based on this custom field. You will have to make other modifications depending on business needs.

Plugin: How do I set default value into an attribute depending business unit?

I have 3 business units (1 parent and 2 children), 3 users (for each business unit), 2 forms (for each business unit) and 1 plugin for the incident entity.
The incident plugin (create, pre-operation) is setting a default value in the attribute 'Case Origin' (caseorigincode) depending on user's business unit.
My problem is what if the user of the parent business unit creates an incident? how the plugin knows from which form that incident is created to set the default value?
What is the best approach to do that?
Thanks.
Unfortunately I don't think there is a way for the plugin to know which form was submitted. However, you could add a hidden field that gets set via javascript to something different for each form. Then, in the plugin you could query that field to see which form was used.
Be sure to check for null/empty as well, because the update could have been submitted programmatically without the use of a form.
IIRC all CRM entities (both stock and custom) should have a OwningBusinessUnit attribute which is an EntityReference to the Business Unit the record's Owner belongs to.
That should tell you exactly from which BU the record is being created.
(NOTE: The question is inconsistent, since it is stated that caseorigincode is set depending on the BU at first, then it asks about forms. I assume the first is the actual logic: check the BU to set the field)
(NOTE #2: This could be accomplished through a workflow aswell: Check Condition on Owner's BU and Update Record accordingly. Run on create.)
Given a user can only be a member of one business unit then you shouldn't need to worry about which form it was created in. Simply get the SystemUser from the EntityReference of the created by user and use the BusinessUnit EntityReference that provides you with.

How can I map fields from Product to Order Product and Product to Quote Product in CRM 2011

can anybody please let me know how can I map field from Product to Order Product and Product to Quote Product in CRM 2011.
CRM doesnt allow us to direct map.
You can't map these using attribute mappings.
One way around this is to write plugins on the PreCreate so that at least when you save the record it populates the data on save.
For plugin reference, the Quote Product entity is called quotedetail and the Order Product entity is called salesorderdetail.
Another other way around this, if you only need it firing on the UI, is create some javascript that triggers during onload of the form and populates this data for you.
If you want a no code method you could fire a workflow on create of the Order/Quote product and populate the fields from the product using an update. Only downside to this is the workflow runs asynchronously so you cannot predict when this mapping data will hit the record.
Finally, if you want another no code way to achieve this, and you don't mind investing a little money in a Formula Rules Engine tool I'd recommend looking into Formula Manager by xRM Consultancy and North 52 (Link to Formula Manager). This allows you to set up formulas on both the UI and Server Side which would do all of this mapping for you.
If you want a no code method you could fire a workflow on create of the Order/Quote product and populate the fields from the product using an update. The only downside to this is the workflow runs asynchronously so you cannot predict when this mapping data will hit the record.

How to add value to a field from another lookup field?

I have a custom entity Partnership in which I have one lookup field contacts.
now I want to add the name field value of the partnership from contact fullname in time of creation of Partnership.
is it possible with the help of pre-existing configuration settings,(without plugin or web resource)
Thanks.
Without using a plug-in or web resource you have a couple options.
1- You can configure the mappings between the 2 entities by going to the Entity (contact) -> Relationship -> Mappings -> and add a new mapping there. For this to work though, you will need to create the child record from the subgrid of the contact, and if the contact changes it won't update the values. So it may or may not be an ideal solution for you.
2- You can create a workflow rule that runs on create and/or update of the Partnership record that pulls the value from the parent contact onto the partnership record. The downside of this is that workflows are async so you won't see the update for a few seconds and refresh the Partner record.
Hope this helps.
If you want to be able to click the "New Partnership" button in the CRM ribbon, then select a contact, and have the name of the contact, be used to populate another field on the form, you will have to use JavaScript. There is no configurable way of doing it.
If you'd like the value to be populated before it is saved in the CRM database, you could use JavaScript, or a custom Plugin. If you'd like the value to be updated after the record is created, you could use a workflow.
You'll have to use one of those three methods to populate the field. The real question I have though, is why are you bothering to populate the field in the first place? You can add the full Contact name to any view, so I don't see a real big reason to include it.

CRM 2011 Filtering view on related record type

I want to create a new view for the activities entity. My aim was to show only the activities that were related to a record of a certain type eg account. But when i was creating it i saw that aside from saying if it contains data or not, and for specific records, there isnt an option for entity type.
I can understand why this isnt an option in the list, as its not really something people would need to do, but is this possible at all?
Thanks
Create an Advanced Find and specify the following criteria:
Look for: Activities
Related > Regarding (Account)
This will get you all activities which are related to an account.

Resources