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

Auto-Populate a field between Accounts and Case entities in Customer Self Service Portal

Hello,

Recently, I have installed the "Customer Self Service Portal".

I have added in the "Case" entity a Country field (Option Set) which contains a list of countries, and I have created another Country field (Option set) in the "Account entity".

 

Account Country Image 
Case Country Image 

 

What I want to achieve is the following:

When I open a new case with a current user, the customer and contact field by default are auto-populated for this user.

 

Demo 

Therefore, I want to implement the same process to auto-populate the country value from the "Account" entity for this current signed-in user and make this field as "Read-only or (disabled)".

As a result, when I click on "Open a new case" the country field will be filled for the users so they don't have to choose the country from the drop-down.

Can someone please explain in detail and provide an example to achieve the following scenario?

Any help would be greatly appreciated.
Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Satish-Reddy
Continued Contributor
Continued Contributor

You can add custom JS to do client-side manipulation easily by jQuery. This can be done by editing the entity form.

 

Assuming that you have a country field stored on portal user (contact) entity:

then, with Liquid Object, you can access {{user.field_logical_name_on_contact}} 

 

$(document).ready(function() {

$("#field_logical_name_on_case").val({{user.field_logical_name_on_contact}});

});

 

OR

 

If you don't have country field on contact (portal user), then you can use account also. 

// Replace GUID of account

{% assign account = entities.account['936DA01F-9ABD-4d9d-80C7-02AF85C822A8'] %} 

$(document).ready(function() {

$("#field_logical_name_on_case").val({{user.field_logical_name_on_contact}});

});

 

 

Thanks

Satish

https://pascalcase.com

 

View solution in original post

4 REPLIES 4
Satish-Reddy
Continued Contributor
Continued Contributor

You can add custom JS to do client-side manipulation easily by jQuery. This can be done by editing the entity form.

 

Assuming that you have a country field stored on portal user (contact) entity:

then, with Liquid Object, you can access {{user.field_logical_name_on_contact}} 

 

$(document).ready(function() {

$("#field_logical_name_on_case").val({{user.field_logical_name_on_contact}});

});

 

OR

 

If you don't have country field on contact (portal user), then you can use account also. 

// Replace GUID of account

{% assign account = entities.account['936DA01F-9ABD-4d9d-80C7-02AF85C822A8'] %} 

$(document).ready(function() {

$("#field_logical_name_on_case").val({{user.field_logical_name_on_contact}});

});

 

 

Thanks

Satish

https://pascalcase.com

 

View solution in original post

Hi @Satish-Reddy ,

Thanks for your reply.

Actually, I am new to the PowerApps portal and I am still learning this.

1. The country field stored on Accounts not (Portal Account) here is a screenshot:
CaptureaCC.PNG

This field should be in (Portal Account Form)?

2. How to get the GUID of the account based on the current user signed in?
In case, if I specify a GUID account it will only fetch the results for this account, so it should be based on the current user signed in.

3. Do you mean field logical name which is the one that I highlighted in the screenshot below?
Capture1.PNG

If yes, and I have replaced the code you mentioned with this form below, how this jQuery code will read this field name since I haven't initialized a variable for this logical field?

{% assign account = entities.account['CURRENT USER SIGNED IN'] %} 

$(document).ready(function() {

$("#new_countryofaccount").val({{user.new_countries}});

});

4. This code should be added inside the Web Template of Customer Service - Create Case?

I would be most grateful if you could provide screenshots of the following scenario so I can understand everything.

Looking forward to your response.
Thanks again!

Satish-Reddy
Continued Contributor
Continued Contributor

1. Not 100% sure. Let's keep the attribute on the portal form, to be on the safer side. 

2. I can see Contact and Customer (not sure what is the customer here, account?) on the case form (Demo link).

If one of them is the account, you can get account GUID from jQuery. Or If account and contact are related in CRM, then you can retrieve something similar to this

{{user.parentcustomerid}}

 assuming parentcustomerid is the lookup field.

3. That's the correct way of getting a logical name. I didn't understand later part of your question here. We are using Liquid Objects here. More documentation on liquid here: https://docs.microsoft.com/en-us/powerapps/maker/portals/liquid/liquid-objects

4. Not a web template, there is a JavaScript code window where you can write behind the page of the entity form. 

 

Considering the state we are in, I guess we need to go back and forth on this thread. We can do remote desktop and I can help by connecting to your instance if that's okay. Let me know your timezone, I am in IST. I am signing off for the day. 

Hello @Satish-Reddy ,

Thanks for the screen share, and your support.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,419)