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 Apps
Answered

Model Driven

(0) ShareShare
ReportReport
Posted on by 46

Hi, How to  autogenerate  projectname with above projectid as Lookup fieldmd.PNG

Categories:
I have the same question (0)
  • timl Profile Picture
    37,285 Super User 2026 Season 2 on at

    @ELango 

    Model driven apps are defined through data. Therefore you'll need to create a Project table and to add a 1-to- many relationship between this table and your Feedback_UserProject. This process will add a Project look up to your form.

  • ELango Profile Picture
    46 on at

    Hi @timl , Yes we have another table called Project master in that we have field called project name but which is text field  not lookup field

  • Bipin D365 Profile Picture
    971 on at

    Hi @ELango ,

     

    You can easily acheive this with Javascript.

     

    Javascript will check if Project Id lookup contains data then get the projectname using Xrm.Webapi.

     

    Register your code on Onload of the form and onchange of Project ID lookup.

     

    Other option is to use Real Time Workflow to auto populate Project name.

     

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: https://xrmdynamicscrm.wordpress.com/

  • ELango Profile Picture
    46 on at

    ELango_0-1640592827333.png

    I have used this Code. But it shows error

  • Bipin D365 Profile Picture
    971 on at

    Hi @ELango ,

     

    I have written below code and it works on my machine.

    function SetProjectName(executionContext)
    {
    	alert(1);
    	formContext = executionContext.getFormContext();
    	if(formContext.getAttribute("msft_emergencycontact").getValue()!=null)
    	{
    		alert(2);
    		var projectId= formContext.getAttribute("msft_emergencycontact").getValue()[0].id;
    		projectId=projectId.replace('{','').replace('}','');
    		Xrm.WebApi.online.retrieveRecord("contact", projectId, "?$select=fullname").then(
     function success(result) {
     var fullname = result["fullname"];
    		alert(fullname);
    		formContext.getAttribute("msft_testsolutioncomparertool").setValue(fullname);
     },
     function(error) {
     Xrm.Utility.alertDialog(error.message);
     }
    );
    	}
    }

     

    Please replace below values - 

     

    msft_emergencycontact ->your Project ID lookup field schema name

    contact -> Your Target Entity Name (Project Lookup )

    fullname -> Text field schema name from Project master table

    msft_testsolutioncomparertool-> Project Name schema name

     

    bipinshan_0-1640606005510.png

     

    bipinshan_1-1640606049704.png

     

    bipinshan_2-1640606072772.png

     

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: https://xrmdynamicscrm.wordpress.com/

  • ELango Profile Picture
    46 on at

    Hi @bipinshan , It works fine ,but it  doesnot fill the  projectname instantly .Once Projectid is given and click Save button during at that time only Projectname is  populated. And again We have to click save button,so that only It  will save  project name in the table.It will take Two steps. 

  • Verified answer
    Bipin D365 Profile Picture
    971 on at

    Hi @ELango ,

     

    Yes, because Xrm.Webapi runs asynchronously and will run in background.

     

    You can try creating real time workflow/Plugin to set the Project Name on save.

     

    Also, you can make the Project Name field Read only to not allow end user to set this value.

     

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: https://xrmdynamicscrm.wordpress.com/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard