Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Display Webresource Image depending on fields value

(0) ShareShare
ReportReport
Posted on by

Hello, 
I'm trying to display a WebResource depending on a field value (Choice value)  in a form, I've done this before without having issues. 
This time I noticed that the displayed image isn't saved after I save the new entity. That means as I open the entity previously saved, I have to manually change the field value to make the picture appear again. 

JSScript used is below to found. 


function onload(){
debugger;

var ContactType= Xrm.Page.getAttribute("FieldLogicalName").getSelectedOption();

if (ContactType != null){
Xrm.Page.ui.controls.get("WebResource_contactA").setVisible(false);
Xrm.Page.ui.controls.get("WebResource_contactB").setVisible(false);
Xrm.Page.ui.controls.get("WebResource_contactC").setVisible(false);
Xrm.Page.ui.controls.get("WebResource_contactD").setVisible(false);
Xrm.Page.ui.controls.get("WebResource_contactE").setVisible(false);
Xrm.Page.ui.controls.get("WebResource_contactF").setVisible(false);

if(ContactType.value==707570000){ // A
Xrm.Page.ui.controls.get("WebResource_contactA").setVisible(true);
}
else if (ContactType.value==707570001){ // B
Xrm.Page.ui.controls.get("WebResource_contactB").setVisible(true);
}
else if (ContactType.value==707570002){ // C
Xrm.Page.ui.controls.get("WebResource_contactC").setVisible(true);
}
else if (ContactType.value==707570003){ // D
Xrm.Page.ui.controls.get("WebResource_contactD").setVisible(true);
}
else if (ContactType.value==707570004){ // E
Xrm.Page.ui.controls.get("WebResource_contactE").setVisible(true);
}
else if (ContactType.value==707570005){ // Default
Xrm.Page.ui.controls.get("WebResource_contactdefault").setVisible(true);
}
}
}

 

Am I missing something ? 
Thank you

Categories:

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard