Creating a Relationship Between Order Product (salesorderdetail) and Service Activity (serviceappointment) - dynamics-crm

We are using Microsoft CRM 4.0 to run a consulting business. Its working pretty well but we want to simplify the way we are doing some things. What we want to do is create an Order (salesorder) with multiple Order Products (salesorderdetal). So good so far.
Next I want to be able associate each Order Product (salesorderdetail) with a Service Activity (serviceappointment), this representing that this billable line item in the order is actually going to be fulfilled as a consuting engagement.
The problem is, I can't seem to be able to create an association between the Order Product (salesorderdetail) and Service Activiy (serviceappointment). It simply doesn't appear in the drop downlist.
Can anyone think of a reason for this? I've seen some posts about relating field mapping between Quote Product, Order Product, Opportunity Product and Invoice Product, but that isn't quite what I am after.
Any suggestions gratefully received - even if it is an explaination of why its not possible.

I created a simple 1:N mapping from Case to Invoice. The Case records its ID and Title in custom fields in the Invoice. Unfortunately this does not allow for product creation as children of the Invoice, so that should be created as a custom code workflow.

Related

Sum Quantity from Opportunity Product Entity to a specific Field on an opportunity within the opportunity table

I have a list of opportunity product lines associated to opportunities that I want to pass to a field within the opportunity table so users can see this within the opportunity table view. The products in the opportunity lines are Number of learners. For projecting onboarding numbers for the month I want to add one field to my opportunity entity.
Total number of learners
This field would be populated by the total quantity of all "learners" products in the opportunity product lines.
I have tried a roll up field, but I can't seem to get it to sum up the quantity of products to appear within the new field created in the opportunity entity.
What features of Dynamics CRM could help me achieve this? MS workflow?
Rollup
Product Line
Rollup field on Form
rollup field should solve your req.
If that does not solve your problem, Then you can create Power autome/ cloud flow.
If not you can create Plugin
If not Javascript.
But my best bet or choice would be rollup and then cloud flow.

Update a existing record instead of creating new record of same entity in MS CRM

I have work order product entity which have product, status and quantity field in MS CRM online. When user tries to create a new record of work order product entity, quantity of existing work order product record with same product should be increased instead of creating new work order product record (without letting user know). Can anyone explain how to achieve this requirement ? This should work for creating record by form or by data import/export.
You must write a plugin in the creation event (post operation) of the order product. In this plugin you need to check if you have another ordering product with the same product.
If so, you must increase the quantity of your existing product order and delete the new one.
If you want to have a good user experience, you can send an alert to your user to inform them of this logic when creating a new order product with the same product as that of an old one.

Product price changed while creating order

What is the DDD way of handling the following scenario:
user enters Order Create screen and starts creatingnew Order with OrderItems
user chooses ProductX from products catalog and adds quantity
OrderItem for ProductX is created on Order and user goes on adding another product
in the meantime, before Order is saved, admin changes price for ProductX
Assuming Product and Order/OrderItem are separate aggregates, potentially even separate bounded contexts, how is this handled?
I can think of several options:
optimistic concurrency combined with db transactions, but then if we broaden the question to microservices where each microservice has its own db - what then?
joining everything into one giant AR but that doesn’t seem right.
introduce a business rule that no product prices are updated during the point of sales working hours but that is often not possible (time triggered discounts, e.g.)
What is the proper DDD/microservices way of solving this?
What is the proper DDD/microservices way of solving this?
The general answer is that you make time an explicit part of your pricing model. Price changes made to the product catalog have an effective date, which means that you can, by modeling time in the order, have complete agreement on what price the shopper saw at the time of the order.
This might introduce the concept of a QuotedPrice as something separate from the Catalog price, where the quote is a promise to hold a price for some amount of time.
To address this sort of problem in general, here are three important papers to review:
Memories, Guesses, and Apologies -- Pat Helland, 2007
Data on the Outside vs Data on the Inside -- Pat Helland, 2005
Race Conditions Don't Exist -- Udi Dahan, 2010
I think one way to solve this through is Events. As you said, Product and Order can are very least separate aggregates, I would keep them loosely coupled. Putting them into one single aggregate root would against Open/Close and Single Responsibility Principle.
If a Product changes it can raise a ProductChanged event and likewise of an Order.
Depending on whether these Domain-Objects are within the same service or different service you can create a Domain-Event or an Integration event. Read more about it here.
From the above link:
A domain event is, something that happened in the domain that you want other parts of the same domain (in-process) to be aware of. The notified parts usually react somehow to the events.
I think this fits perfectly to your scenario.

CRM - Transfer list of products from opportunity to order on close opportunity

When closing an opportunity as won, a workflow will run and create an Order based on some of the fields in Opportunity. We are not currently transferring the product list from opportunity to order. We are aware that there is a default relationship between opportunity and product called 'opportunityproduct'.
We need to know if there is a way to transfer the Products from 'opportunityproduct' to 'orderproduct'. Can this be achieved solely through the use of CRM workflow? Or would we need to create a custom Plugin?

Product slug not working in CRM 2013 Email templates

I have a business requirement that execs are really wanting to see. In our lead and email templates we have a few of our products listed. The products themselves are pretty stable but the prices are of course subject to change.
I'm OK with hard coding the product name into email but I was hoping the price could be a slug that get's resolved.
We only have one price list so nothing to worry about there.
I see no way to get access to the product and or price list entities through the data field values dialog.
So my thought was to create the 2-4 fields in the lead and opportunity entities. Then create a background workflow that takes the price from the price list and sets those fields.
Then when an email is generated I can access those hidden fields as they will be available through the lead or opportunity entity.
Any thoughts, concerns, better approaches?
Unfortunately CRM's email template system is not capable of what you describe out of the box. As you have discovered it will only permit you to insert placeholders from, or assocated with, the primary entity. It won't let you insert fields from other entities. What you suggest as a workaround is possible but it's not an ideal solution as you'll have these 2-4 redundant fields on each record type that contain duplicated data from the price list.
If you have any experience with creating custom workflow activities using the SDK then the best solution here is to create a custom activity that accepts either an draft Email or Email template as a input parameter, instantiates the email if required, loads the price list data, and performs your own custom placeholder replacements.
I've done this on a few projects in order to pass multiple entity records into the template, or to insert complex tables into emails by loading data from relationships. See the screenshots below for an example of how I've configured the email template and dialog process to pass both an 'Account' and 'User' record into the email template.

Resources