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 / How to autogenerate Pr...
Power Apps
Unanswered

How to autogenerate Primary Name field in custom CDS Entity?

(0) ShareShare
ReportReport
Posted on by 3

Primary Name field is by default "Required". How to fill this field by GUID or random number on save?

I have the same question (0)
  • Kevin23 Profile Picture
    47 on at

    You could do a few things. 

    • Change the requirement level of the field to Business Recommended or Optional (you'll need to do this for all of the below options).
    • Use the D365 autonumber service to create an autonumber and populate it in the field. You can easily acheive this with XRMToolbox and a plugin.
    • Use javascript to either generate a GUID or copy the recordid field to the name field
    • Use workflow to copy values from other fields to the name field (this would be the easist and generally recommended thing to do as the primary name field is used to display records in lists in D365/model driven apps

    Kev

     

  • BranoBeno Profile Picture
    3 on at

    Thanks for tips. For now most comfortable was to use JavaScript in attributeOnChange on form when some required field is changed:

     

     var Sdk = window.Sdk || {};
     (function () {
     this.attributeOnChange = function (executionContext) {
     var formContext = executionContext.getFormContext();
     var primaryname = formContext.getAttribute("cr309_primaryname").getValue();
     if(primaryname==null){
     var chars = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
     var str = "";
     for(var i=0;i<36;i++) {
     var str = str + ((i == 8 || i == 13 || i == 18 || i == 23) ? "-" : chars[Math.floor(Math.random()*chars.length)]);
     }; 
     formContext.getAttribute("cr309_primaryname").setValue(str);
     }
     }
     }).call(Sdk);

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
Haque Profile Picture

Haque 103

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
wolenberg_ Profile Picture

wolenberg_ 67 Super User 2026 Season 1

Last 30 days Overall leaderboard