Sometimes, we may need to set a default value for the entity field in portal forms. In this post, we are going to discuss, how we can leverage entity form metadata to fulfill this requirement.
Requirement
Identify if the case is created from Dynamics 365 Portal.
Solution
If you have worked with custom service module earlier then you might be aware of the Case Origin (caseorigincode) field which is an option set field. This field is used to configure case origin, for example, if the case is reported through phone, email, web etc. We can reuse this field to identify if the case is reported from the Customer Portal. Let’s see how we can implement this using the following steps,
- First, add an option for Portal in case origin field, navigation to Settings->Customizations->Customize the system from the top navigation bar.
- Navigate to Fields under Case entity and open case origin field.
- Click on Edit button and add a new option for Service Portal.
**Keep note of the value of the Service Portal
- Save and publish your changes.
- Navigate to Portals->Entity Forms from the top navigation bar.
- Open your case entity form and Navigate to Entity Form Metadata section
- Click on + sign, to create new Form Metadata record
- Set Type as an attribute and set attribute name.
- Navigate to Set Value On Save and use following option.
**Make sure the value is matching to your Service Portal option value
- Save and Close your changes.
Now when you will create the case from Portal, case origin will be set as,
I hope it will help someone!!