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 / Evaluate a field with ...
Power Pages
Answered

Evaluate a field with a query field in a Form - Power Pages

(0) ShareShare
ReportReport
Posted on by 312

Hello community, I am working with a portal in power pages.

 

I'm trying to evaluate a field on my form with a quick form value.

 

That is, I have this form related to a batch entity, and when I select a Product Batch, the Details are displayed.

 

But I want the Quantity field not to exceed the Available Quantity of the quick form based on the batch selected in the Custom JavaScript of the form.

 

MartinVargas_0-1711219009192.png

 

Any ideas?

 

Categories:
I have the same question (0)
  • GWham1 Profile Picture
    on at

    On your form add a custom validator

     

    https://learn.microsoft.com/en-us/power-pages/configure/add-custom-javascript

     

    in the evaluationfunction put your logic. You can get the value from the available quantity using jquery. 

     

     

  • Verified answer
    MartinVargas Profile Picture
    312 on at

    Hi @GWham1 Indeed, I had to add a custom field with metadata applying a filter based on the product batch field, leaving my JavaScript as follows:

     

    $(document).ready(function(){
     $("#crd4f_cantidadarticulo").change(onEvaluateQuantity);
    });
    function onEvaluateQuantity()
    {
     // Add event validator
     if (typeof(Page_Validators) == 'undefined') return;
    
     // Create new validator
     var newValidator = document.createElement('span');
     newValidator.style.display = "none";
     newValidator.id = "quantityValidator";
     newValidator.controltovalidate = "crd4f_cantidadarticulo";
     //newValidator.errormessage = "No puedes sobrepasar la cantidad disponible.";
     newValidator.errormessage = "<a href='#crd4f_cantidadarticulo_label' referencecontrolid='crd4f_cantidadarticulo ' onclick='javascript&colon;scrollToAndFocus(\"crd4f_cantidadarticulo_label\",\" crd4f_cantidadarticulo \");return false;'>No puedes sobrepasar la cantidad disponible.</a>";
    
     newValidator.evaluationfunction = function() { 
     
     var EstablishedQuantity = $("#crd4f_cantidadarticulo").val();
     var QuantityAvailable = $("#crd4f_cantidaddisponible").text();
     var NewEstablishedQuantity = parseFloat(EstablishedQuantity.replace(",", ""));
     var NewQuantityAvailable = parseFloat(QuantityAvailable.replace(",", ""));
     
     if (NewEstablishedQuantity > NewQuantityAvailable) {
     //$("#crd4f_cantidadarticulo").val('')
     return false;
     } else {
     return true;
     } 
     };
     Page_Validators.push(newValidator);
    }

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 61

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 40 Most Valuable Professional

#3
DP_Prabh Profile Picture

DP_Prabh 26

Last 30 days Overall leaderboard