Optional Model Validation in Razor Page - validation

I have a "create account" form where I would like to collect data related to more than one model. While this is easy to accomplish, I am not able to figure out how to make the validation optional in the case where I would like to make something optional. Consider the example below.
Pseudo Code Form
Create Account
Account Name
…
Create Primary Contact
Contact Name
Contact Email
Create Contact Address (Optional)
[ ] Skip Address
Address Type
Street
City, State zip
In this example, I would like the validation to run on "create account", "create primary contact," and on the "create contact address" if the "Skip Address" is not selected. Please note that each of the sections above has its own model and own database repository.

Related

Fetch value of a field from one entity to second entity based on the lookup field selected in second entity using Fetch XML

I am new to CRM. I have a requirement where I have an "account" entity and a "contact" entity. In contact form I have a lookup field for searching account name which is stored in account entity. When I select an organization through lookup, the contact number of that organization should be fetched and saved in another field in contact form. I need to do it with fetch XML.
Option 1: You can do a no-code solution by mapping fields between account & contact.
Option 2: If you don't want a physical copy of field value in both entity, use Quick view form of Account lookup to just display the fields in contact without storing redundant data.
Option 3: If you still want to store the value onchange of account, retrieve it & set it in contact field. This step by step guide will help you to build fetchxml & use it in JS. Your question doesn't say if you are stuck in query or any error.

Link Lookup Table to Account Name Field

In CRM Online I need to link the Account Name field in the Account entity to a lookup table of imported and approved company names. The goal is to require users to pick from an approved list instead of letting them make up a company account name. I know there is an Account Name lookup in Contacts which uses existing Account Name records, but I need the lookup in the Account entity. Thanks for any tips.
If you are referring to a different entity as LookupTable, then create a relationship between Account ans the Lookup Table entity. After that you can use that entity as Lookup attribute in Account entity
CRM renders a Lookup control for a 1:N relationship. What you are trying achieve would fall more into a data validation scenario where users can enter account names from a pre-set list of names.
You can leverage a new event introduced in CRM 2016 - addOnKeyPress which can be easily used to build an autocomplete feature which would be more inline with what you are trying to achieve. If a user doesn't "pick" a value instead types anything in disregarding the autocomplete use attribute control's setNotification to set an error message which would invalidate the save preventing the user from saving the record.

CRM 4 - Add Account specific field to Opportunity

My Account entity has an Account Manager field. I would like to add this same field to Opportunity as a reference. Is there a way to add this field to Opportunity and make it point to the attribute "Account.Account Manager"?
I am using MS Dynamics CRM 4
What you're asking for is copying the field "Account Manager" in entity "Account" to entity "Opportunity", is it?
If that is what you want, you need to create a field named "Account Manager" (or whatever you wish to) in the "Opportunity" entity form; the field type being the same. And you need to have some kind of workflow/plugin/javascript to update the field in "Opportunity" form with the same value as present in the "Account" form.
EDIT: Based on your comment, I've edited the answer. You can achieve it by two means:
Have some kind of workflow/plugin populating the field in
Opportunity form from that of the Account form.
Fetch the value of the Account field by javascript on Opportunity
form load and display it in a field.
Also, you might want to make the field read-only in Opportunity form.

Pulling data from one entity onto an Email form within a Workflow

I have a workflow that will fire once a form field changes. The workflow checks the value and then sends an email if one particular value is selected. That much I've managed to figure out.
Now I need to pull a field value from a separate entity to populate the "to" field of the email. We have a Configuration entity that stores the value of a distribution list - we want to pull this into the email that the workflow generates.
I've created an N<>1 relationship between the primary entity and the Configuration entity, however I only see the Entity and not the entity's Fields in the email form assistant. Any idea how I can pull that data onto the email form?
If you see the entity populated under "Look for" and then in the drop down under that you see no values? I'm guessing in your configuration entity your email address you want to use for the email recipient is a text field. In order for the form assistant to populate the second drop down, the field types must match up - or in this case for a field to show up as useable for the "To" field, it needs to be an Account, Contact, User, etc... values you can send an email to.
My suggestion is create a Contact record that has the proper email address and either relate that to your base entity in place of your configuration entity (if possible) or relate your configuration entity to Contact and populate the new lookup on the configuration entity accordingly.

Dynamics CRM - Text inside customer field on case entity won't update

I have a problem with getting the text inside the customerid field on the case-form to update
As you can see on the picture above, I've created a contact named "Test Contact" and an account named "Test Account".
I have a workflow running in the background with the condition: if a contact is in the customer-field AND the contact belongs to an account, then update the record with moving the customer (which is a contact) to the contact field, and then get the company in the customer field.
The problem is (as shown in the picture) that the customer field don't show the right text. Because customer details is updated with "Test Account" which is the company that "Test Contact" belongs to. Also, if I click on the "test contact" I also get in the "Test Account" form. So all the references is okey, but the text is wrong.
I've tried different ways to solve this problem, but as for now, I'm a bit short on what to do next.
The workflow
Update record
I was able to solve the problem with an wait condition that timedout until the contact field had data, and then got the company of the contact.
It takes a few seconds extra, but at least it solved the label error

Resources