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 Apps / help for newby in Java...
Power Apps
Answered

help for newby in Javascript

(0) ShareShare
ReportReport
Posted on by 465

Hi all
I try to write a little javascript (it's one of my first times copying them from some post found in communities) to change visualization of a lookup field, if statecode of opportunity is eq 0.
This under is my java and it's working until the rows in green ... the message appears correctly with correct statecode of opportunity (from parent form).
Then I've inserted the get() to try to retrieve the GUID of the views of my lookup column (and other data found in posts that I read).

Where I'm wrong in this script? (this is for me a learning)
How can I retrieve the GUID of all visualization of my lookup column?

Thanks in advance for any help or suggestion

 

var formContext = e.getFormContext();
if (StatoOpportunity === 0) {
  var strDescrizione = "0";
  // Xrm.Navigation.openAlertDialog({ confirmButtonLabel: "Ok", text: " valore - " + strDescrizione, title: "Stato Opportunity = " + StatoOpportunity}, { height: 500,     width: 500 }).then(function (success) {console.log("Alert dialog closed");},function (error) {console.log(err.message);});
  //
  // Getting the value of Case cr07a_categoriaopportunita id
  var CategDoc = formContext.getAttribute("cr07a_categoriaopportunita").getValue();
  // Getting the GUID of the lookup record
  var CategDocId = CategDoc[0].id;
  // Getting Name of the lookup record
  var CategDocName = CategDoc[0].name;
  // Getting Entity Name of the lookup which entity, the lookup record is belonging to.
  var CategDocEntityType = CategDoc[0].entityType;
  //
  Xrm.Navigation.openAlertDialog({ confirmButtonLabel: "Ok", text: " CategDocId - " + CategDocId, title: "CategDoc"}, { height: 500, width: 500 }).then(function (success) {console.log("Alert dialog closed");},function (error) {console.log(err.message);});
}

 

 

 

 

I have the same question (0)
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello,

    What's the trigger of your code to be executed? Is it form load/field change/ribbon button click??

  • Verified answer
    DiePic Profile Picture
    465 on at

    Hi @a33ik and thanks for reply.
    On form load, I want change the visualization of a lookup column (cr07a_categoriaopportunita) based on opportunity[codestate].value.
    I find my solution here:
    https://powerusers.microsoft.com/t5/Microsoft-Dataverse/change-visualization-in-a-form-table-in-dataverse/m-p/2526841#M36306

    ...

    thanks @a33ik for your help

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 93 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
Valantis Profile Picture

Valantis 49

Last 30 days Overall leaderboard