Hi everyone,
In the entity form, I have 2 fields. one is License key, data type is "Text". The other one is prefix number, it's a lookup field.
We have another table called license management as below, which contains license key and prefix number.
License management table
License Key | Prefix Number |
AAA-AAA-AAA | 8 |
BBB-BBB-BBB | 80 |
I hope that when I input license key in the entity form, Prefix number field will display the corresponding number automatically based on License management table.
Due to our needs, both fields are required and we don't want user to make selection in Prefix number field.
Example:
If we input AAA-AAA-AAA in License key field, Prefix number lookup will only show the record whose prefix is "8".
Any idea about it, pls kindly share with me.
Hi @Audreyma ,
Please read carefully article that I share before. It shows with an example on how to both call and get an output. On your web template you need to shape return data in a json format, so please do not add any additional html tags. Your output should look something like this:
{% fetchxml demoData %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="cr_autoannounce_prefix">
<attribute name="cr_licensekey" />
<attribute name="cr_autoannounce_prefix" />
<filter type="and">
<condition attribute="cr_licensekey" operator="not-null" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
{
"totalcount": {{ demoData.results.total_record_count }},
"morerecords": {{ demoData.results.more_records }},
"page": {{ demoData.params['page'] | default: 0 }},
"results": [
{% for item in demoData.results.entities %}
{
"cr_licensekey": "{{ item.cr_licensekey }}",
"cr_autoannounce_prefix": "{{ item.cr_autoannounce_prefix }}"
}{% unless forloop.last %},{% endunless %}
{% endfor -%}
]
}
You can also pass an entered license key and get a proper prefix so you don't need to query everything. See this article for more details.
Hi @OOlashyn
Thank you for your sharing.
I can get the data through the below fetch xml in my test page, but got stuck about how to output corresponding data in another web page through Javascript.
{% fetchxml demoData %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="cr_autoannounce_prefix">
<attribute name="cr_licensekey" />
<attribute name="cr_autoannounce_prefix" />
<filter type="and">
<condition attribute="cr_licensekey" operator="not-null" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
<b>Total Records:</b> {{demoData.results.entities.size}}</br>
{% for result in demoData.results.entities %}
License key: {{result.cr_licensekey}}</br>
Prefix number: {{result.cr_autoannounce_prefix}}</br>
{% endfor %}
Fetch xml output in my test page:
I hope that if I input AAAA-AAAA-AAAA in license key field, prefix number will show 80.
Could you give me some more instructions about Javascript?(sorry for my poor knowleage about code writing)
Hi @Audreyma ,
What you can do is when user enters the license key query data from the system and based on the response populate the field. Unfortunately, portal Web API doesn't support read operations (at least yet), so you will need to use Web Page as an API approach. Basically, you create a web template with fetchxml query to which you can pass different parameters via url query string and create a web page based on that template. Then you can just call that page via javascript. You can find more about this approach here - https://colinvermander.wordpress.com/2017/04/17/dynamics-365-portals-use-liquid-to-return-json-or-xml/
Any ideas about this issue?
Lucas001
60
Super User 2025 Season 2
Fubar
55
Super User 2025 Season 2
surya narayanan
35