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 Pages / After created record f...
Power Pages
Unanswered

After created record from relatated record tab auto populate lookup field

(0) ShareShare
ReportReport
Posted on by 4

Hi everyone, 

 

I have a multistep form and i need to auto populate lookup field.

 

Screenshot 2024-05-17 172329.png

This is modal and it is out of box. I implemented from power app management. 

Screenshot 2024-05-17 173350.png

 

Screenshot 2024-05-17 173922.png

 

I belive that this should be doable in power pages management. I tried to write javascript code but when i click submit button, the record is saving automatically. I used this code but i couldn't handle the get record id after saving dataverse but before closing this modal. And how can i get the record id which is created in my account information step to set lookup field.

 

 

document.addEventListener('DOMContentLoaded', function() {
 var button = document.getElementById('InsertButton');
 var entityLogicalName = $("#EntityFormControl_EntityFormView_EntityName").val();
 console.log(entityLogicalName);
 // Getting the Record ID 
 var recodId = $("#EntityFormControl_EntityFormView_EntityID").val();
 console.log(recodId);
 if (button) {
 button.addEventListener('click', function(event) {
 // Getting the Entity Logical
 var entityLogicalName = $("#EntityFormControl_EntityFormView_EntityName").val();
 console.log(entityLogicalName);
 // Getting the Record ID 
 var recodId = $("#EntityFormControl_EntityFormView_EntityID").val();
 console.log(recodId);
 });
 } else {
 console.error('Buton bulunamadı: InsertButton');
 }
});

 

   

 

Categories:
I have the same question (0)
  • fm_skeller Profile Picture
    277 Moderator on at

    You should be able to catch the 'success' message if the record has been successfully created, the message will have the id in the JSON data. However, lookup fields have this behaviour by default if you add a metadata record for the lookup attribute: Configure basic form metadata for Power Pages | Microsoft Learn

    Behind the scenes this functionality does exactly the same by the way:

    	window.addEventListener('message', function (e) {
    		var origin, message;
    
    		if (!window.location.origin) {
    			origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); // IE does not set origin
    		} else {
    			origin = window.location.origin;
    		}
    
    		if (e.origin != origin) {
    			return;
    		}
    
    		try {
    			message = $.parseJSON(e.data);
    		} catch (jsonParseError) {
    			return;
    		}
    
    		if (message.type === 'Success') {
    			e.preventDefault();
    			console.log( message.id);
    
    		}
    
    		e.target.removeEventListener(e.type, arguments.callee);
    	});
    });

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 41 Super User 2025 Season 2

#2
Suriyanarayanan V Profile Picture

Suriyanarayanan V 34

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 26 Most Valuable Professional

Last 30 days Overall leaderboard