cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

Customer Service Portal - Liquid expression to populate field values based on the current contact.

Hello,

In my environment I have the "Customer Self Service Portal", inside this portal there is a "Web Create Case" form. In this form, there is a field for Customer(Account), Contact and another field that I have created called "Services" as an option set. Also, the same Services field exists in the Contact entity. (Each contact can have one service)
Capture.JPGCapture1.JPG
For example:

 

contactid:1
contactname:test
new_services: Office 365

 


What I am trying to achieve is the following:
I want to populate after page load the service value based on the current filled Contact value from the Contact entity.

I have found something similar to my requirement but it's based on "Account" value not the "Contact". Please have a look below:

 

<p>{% assign account = entities.account[{{user.parentcustomerid.id}}] %}</p>

<p><span hidden="" id="optionSetValues">{{account.new_countries.value}}</span>
</p>

window.onload = function(){
  
document.getElementById("new_country").value = document.getElementById("optionSetValues").innerHTML;
document.getElementById("optionSetValues").style.display = "none";

}

 

Can someone please provide an example using liquid expression to get the current contactid inside the form?

Any help will be greatly appreciated.
Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Customer Service Portal - Liquid expression to populate field values based on the current contact.

Hi @Julien2 ,

Do you mean that the "Services" field is a LookUp field in your Case Entity Form, which reference values from the Contact Entity?

Do you want to assign the option set value inside the lookup field value within the Case Entity Form?

 

If the "Services" field is a LookUp field in your Case Entity Form, which reference values from the Contact Entity, please modify above formula as below:

<p>{% assign contact = entities.contact[page.'logic name of Contact field in the form'.Id] %}</p>
<p><span hidden="" id="optionSetValues">{{contact.contactid}}</span>
</p>

<script type="text/javascript">
window.onload = function(){
    document.getElementById("optionSetValues").style.display = "none";
};
document.getElementById("logical name of the services field on Case form").addEventListener("change", function(event){
    document.getElementById("logical name of the services field on Case form").value = 
    document.getElementById("optionSetValues").innerHTML;
})
</script>

using the following Liquid template expression to get the Unique Identifier value (GUID value) of the selected Contact value within the Contact LookUp box:

{{contact.contactid}}

you could use the following expression to get the contact id of current sign in user:

user.contactid

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Responsive Resident
Responsive Resident

Re: Customer Service Portal - Liquid expression to populate field values based on the current contact.

Hey Julien,

 

You dont need the first statement, as you don't need the account anymore. 

Hence removed: <p>{% assign account = entities.account[{{user.parentcustomerid.id}}] %}</p>

 

 

Contact is accessible from user object. hence, I modified the code like this.

<p><span hidden="" id="optionSetValues2">{{user.new_services.value}}</span>
</p>

<script>
window.onload = function(){
document.getElementById("logical name of the services field on Case form").value = document.getElementById("optionSetValues2").innerHTML;
document.getElementById("optionSetValues2").style.display = "none";
}
</script>

Replace the logical name of the services option set above.  

Highlighted
Community Support
Community Support

Re: Customer Service Portal - Liquid expression to populate field values based on the current contact.

Hi @Julien2 ,

Do you want to populate the Services field based on the Contact field value within your Entity form?

Further, do you want to get the current contactid typed inside the form?

 

Based on the needs that you mentioned, I think Liquid page tag could achieve your needs. Please consider take a try with the following workaround:

{% assign contactId = page['logicname of Contact field in the form'].Id %}

 

Then you could use the following formula to get the corresponding Option Set field value and set it into the Services field:

<p>{% assign contact = entities.contact[page.'logic name of Contact field in the form'.Id] %}</p>
<p><span hidden="" id="optionSetValues">{{contact.'loigc name of Services field'.value}}</span>
</p>

<script type="text/javascript">
window.onload = function(){
    document.getElementById("optionSetValues").style.display = "none";
};
document.getElementById("logical name of the services field on Case form").addEventListener("change", function(event){
    document.getElementById("logical name of the services field on Case form").value = 
    document.getElementById("optionSetValues").innerHTML;
})
</script>

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Post Prodigy
Post Prodigy

Re: Customer Service Portal - Liquid expression to populate field values based on the current contact.

Hello @Satish-Reddy  @v-xida-msft ,

Thank you for providing examples.

I have figured out that, the "Services" field type in the form (Case entity) is a Lookup and not an option set. Since in the contact entity the "Services" field is an Option Set.

The Lookup options values have different numbers than the option set values.
For example, all the option set values start with 1000000 since the lookup values contain a GUID.
Option Set:

<option selected="selected" value="" label=" "> </option>
<option value="100000000">Azure</option>

Lookup:

<option value="" label=" "> </option>
<option value="926b6362-c079-e911-a988-000d3aba0bee">Azure</option>


In our logic, we are saying that the services field value inside the contact entity should be equal to the services lookup value. As a result, they will never be equal so the value will be never assigned inside the services field which is the problem that I am facing right now.

I have thought of a workaround that is creating a new "Services" field as an option set type inside the form and removing the other field, but it's not a good idea.

I would like to ask you how can I assign the option set value inside the lookup field value?

I was able to get the value of the right service assigned for the user signed-in using {{user.new_services.value}}.

Looking forward to your response.
Regards,
Julien

Highlighted
Community Support
Community Support

Re: Customer Service Portal - Liquid expression to populate field values based on the current contact.

Hi @Julien2 ,

Do you mean that the "Services" field is a LookUp field in your Case Entity Form, which reference values from the Contact Entity?

Do you want to assign the option set value inside the lookup field value within the Case Entity Form?

 

If the "Services" field is a LookUp field in your Case Entity Form, which reference values from the Contact Entity, please modify above formula as below:

<p>{% assign contact = entities.contact[page.'logic name of Contact field in the form'.Id] %}</p>
<p><span hidden="" id="optionSetValues">{{contact.contactid}}</span>
</p>

<script type="text/javascript">
window.onload = function(){
    document.getElementById("optionSetValues").style.display = "none";
};
document.getElementById("logical name of the services field on Case form").addEventListener("change", function(event){
    document.getElementById("logical name of the services field on Case form").value = 
    document.getElementById("optionSetValues").innerHTML;
})
</script>

using the following Liquid template expression to get the Unique Identifier value (GUID value) of the selected Contact value within the Contact LookUp box:

{{contact.contactid}}

you could use the following expression to get the contact id of current sign in user:

user.contactid

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (10,676)