web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / help for newby in Java...
Power Apps
Unanswered

help for newby in Javascript

(0) ShareShare
ReportReport
Posted on by 463

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
    463 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 840 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 332 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 275

Last 30 days Overall leaderboard