web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / user object in portals...
Power Pages
Unanswered

user object in portals javascript

(0) ShareShare
ReportReport
Posted on by 168
 

 

<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.

 

Categories:
  • Fubar Profile Picture
    17 Super User 2026 Season 1 on at

    'user' is the Contact record.  It only exists when someone is logged into the Portal.

    'user' is a Liquid (server-side) object the {{....}} are telling the server side to write the values into the HTML/JavaScript, the server then gives it to the browser (client-side) which then renders the HTML/JavaScript.

     

    Customer is a complex data type and can accept both Contact and Account records. You appear to be trying to Append() rather than set the values requred. If you look in the Web Template behind the out of the box Create Case you will see the following - you must set as per the first 3 lines

     $("#customerid").val(accountId);
     $("#customerid_name").val(accountName);
     $("#customerid_entityname").val("account");
     

     

     

  • urklnme Profile Picture
    168 on at

    Whomever created the customized create case for my portal must have wiped out the original web template.

     

    Do you know where I might find one?

  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @urklnme 

     

    It is hard to retrieve the web template if is deleted unless it is deactivated. 

     

    Hope it helps. 
    ------------

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

     

  • urklnme Profile Picture
    168 on at

    Yes, I dont have the original web template,  deactivated or otherwise.  The customerid_name field, for example, is not referenced in the web template that I have.

     

    Thought someone might have one that they could share with me.

     

     

  • eugenevanstaden Profile Picture
    441 on at

    @urklnme 

    The user object represents the current logged in user (contact record). You can set it on fields, hidden or visible on the form by mixing the Liquid as you have done above.

    You can also set the Customer to the current portal user in Form Metadata by adding the Customer field
    example:

    eugenevanstaden_1-1649196557806.png

     




    or on the Form itself

    eugenevanstaden_0-1649196511283.png
    Or set the Lookup with Javascript by mixing in Liquid, 
    $("field").val('{{user.id}}');



     

  • urklnme Profile Picture
    168 on at

    Well, I must have done something, somewhere to really mess this situation up. 

     

    Does any one have the original web template for Create Case or know hwere I can get one?

  • Fubar Profile Picture
    17 Super User 2026 Season 1 on at

    How to get the original: Setup a Customer Self-Service Portal in a new instance or in a new Trial.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 18 Super User 2026 Season 2

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#3
CU08101843-0 Profile Picture

CU08101843-0 4

Last 30 days Overall leaderboard