Hi all,
I am trying to get instant updates from CRM to portal. So when a field is changed in CRM then it is instantly reflected in the portal. I am trying to do this as I have created a booking system that needs to reflect synchronous updates if changed on portal or CRM backend.
The issue I am getting is that when I update a field in CRM, the cache seems to take 1-5 minutes to update on the portal side. I cannot have this as it is a booking system and the user needs to see the reflected change in CRM on the portal if it gets updated immediately.
I tried creating a WebAPI following this article (https://readyxrm.blog/2021/01/05/using-the-power-apps-portals-webapi-to-clear-the-portal-cache/) but it seems to only work sometimes. Meaning that sometimes the change is reflected instantly which is great, but then other times it can take 1-5 minutes. Im unsure why this method would only work sometimes? I have done everything in the article and receive no errors in my JavaScript, also all permissions and site settings are set. I have also turned on 'Change Tracking' on the targeted entity with no better result.
Here is my code on the redirect page which should retrieve the latest updated info (registration count) from CRM -
{% block main %}
{% include 'Wrapper AJAX' %}
{% assign RegistrationPage = sitemarkers["CacheRefreshPageTransfer"] %}
{% assign guid = request.params['id'] %}
<script>
function rtc() {
try {
var n = Date.now();
//var timestamp = n.toString();
var guid = "{{guid}}";
//alert(guid);
webapi.safeAjax({
type: "GET",
url: "myURL.com/_api/adx_eventschedules(" + guid + ")?$select=iop_registration_count",
contentType: "application/json",
//data: JSON.stringify({
// "value": timestamp
//}),
async:false,
success: function(res) {
window:location.href = "{{ RegistrationPage.url }}?id={{guid}}";
console.log(res);
}
,
error:function(res)
alert("Error");
}
});
} catch (err) {
alert(err.message);
}
}
$(document).ready(function() {
rtc();
});
</script>
{% endblock %}
As I mentioned sometimes this works and change in CRM is reflected instantly on portal but then other times it takes much longer.
Im wondering if a Power AUtomate flow HTTP request might help here? So It can pull the data from CRM and update on the portal somehow? Just a thought.
Hoping for some help as I have been stuck for 2 days now.
Thanks very much all.