<input type="hidden" id="case-user-contact" value="{{user.id}}" />
<input type="hidden" id="case-user-contact-name" value="{{user.fullname}}" />
<input type="hidden" id="case-user-account_id" value="{{user.parentcustomerid.id}}" />
<input type="hidden" id="case-user-account-name" value="{{user.parentcustomerid.name}}" />​
user object in portals javascript
A User object is referenced in the javascript for the Create Case web template.
Do you know HOW the User object is populated? It does contain the same fields as Contact.
Does it affect how the Customer field is set when creating a new Case from the external portal?
Do you have any insights RE: how the Customer is set when submitting a Create Case form?
So for us Contact and Customer records do have same first and last name, but different email addys.
In the Create Case web template, using fetchXML, I find the Customer that matches the Contact based on first and last name.
{% fetchxml feed %}
<fetch version="1.0" mapping="logical" ouptut-format="xml=platform" distinct="false" >
<entity name = "account">
<attribute name = "accountid" />
<attribute name = "name" />
<attribute name = "micses_firstname" />
<attribute name = "micses_lastname" />
<attribute name = "emailaddress2" />
<order attribute ='micses_lastname' descending='false' />
<filter type = "and">
<condition attribute = "name" operator="eq" value= "{{user.fullname}}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
I remove all Customers from the Customer lookup and append the fetchXML Customer.
$("#customerid").empty();
{% for item in feed.results.entities %} {
let option = document.createElement("option");
option.value = "{{ item.accountid }}";
option.innerText = "{{ item.name }}";
$("#case-user-account_id").val("{{ item.accountid }}");
$("#case-user-account-name").val("{{ item.name }}");
$("#customerid").append(option);
}
{% endfor -%}
All of the above works. However, when I submit the Create Case form, the Case created has the original signed in contact fullname in the Customer field.
Any help will be appreciated. I a am single developer maitaining a D365 Help Desk app and an associated External Customer Portal with no Microsoft support contract.