Skip to main content

Notifications

Power Pages - General Discussions
Unanswered

Basic form lookup renedered as drop down, hide fields based on lookup rendered as drop down value

(1) ShareShare
ReportReport
Posted on by
I have tried the following to get the lookup rendered as a drop down to hide other fields based on its value
 
   function hideShowSections(executionContext) {

      formContext = executionContext.getFormContext();
     
    RequestTypeLookupName = formContext.getAttribute("requesttype").getValue()[0].id;

    var FieldToSHow = formContext.getAttribute("fundingofficial");

   
      if (formContext.getAttribute("requesttype").getValue()[0].name == "Parking")
   
      {
         FieldToSHow.setVisible(true);
   
      } else
   
      {
         FieldToSHow.setVisible(false);
      }
   
   }
 
 
 
Here is another set of code I tried also unsuccessful
 
//# field with the conditional logic
$(document).ready(function () {
  $("#inspectselectionid").change(onDisplaySectionChange);
  onDisplaySectionChange();
});

function onDisplaySectionChange() {
 var varSubject = $('#inspectselectionid').find("setIsDirty(this.id)").text();
 
// if lookup rendered as dropdown is Parking show justification field else hide    
 if (varSubject === "Parking") {
       
    $('#logicalfieldtoshow').parent().parent().show();
 }
 else {
    $('#logicalfieldtohide').parent().parent().hide();
 }}
 

 
  • Suggested answer
    Fubar Profile Picture
    Fubar 7,695 on at
    Basic form lookup renedered as drop down, hide fields based on lookup rendered as drop down value
    The second set of code is closer to what you need as Power Pages does not support the model driven app client side scripting (e.g. formContext) -  Use plain JQuery/JavaScript.
     
    With the second bit of script put in a debugger statement and debug it in the browser - not sure if this line
    $('#inspectselectionid').find("setIsDirty(this.id)").text(); is correct the others look ok 
     
    also in JQuery .change() is deprecated and should now be .on('change', yourfunction)

    Edit: to get the text value from the dropdown you will need to do something like
    $('#fieldschmaname').find("[value='"+ $('#fieldschmaname').val() +"']").text();
    
    //and you will want to check $('#fieldschmaname').val() is not null or empty before that

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard