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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Autofill field in a form in D365/CRM4?

(2) ShareShare
ReportReport
Posted on by 7
When creating an invite by using a form in D365 I'd like for it to automatically fill the 'Expiry Date' field with a date, for example 30 days into the future. How would one go about setting that up?
I have the same question (0)
  • Suggested answer
    PerezAguiar Profile Picture
    Microsoft Employee on at
    Hey!
     
    Perhaps, you can use a Calculated field "responseBy", that automatically populates with this, or a javascript added to the form as a resource.
     
    Regards,
  • Verified answer
    Inogic Profile Picture
    743 on at
    Hi,
     
    Option 1: JavaScript on the Invite Form
    Use this when the Invite is created via a model-driven form and you want the Expiry Date to be populated immediately when the form opens.
    Steps
    1. Create a JavaScript web resource
    2. Add it to the Invite form
    3. Register the function on the Form OnLoad event
    4. Enable Pass execution context
    JavaScript Example
    function setExpiryDate(executionContext) {
        var formContext = executionContext.getFormContext();
     
        // Run only for new records
        if (formContext.ui.getFormType() !== 1) {
            return;
        }
     
        var expiryDateAttr = formContext.getAttribute("new_expirydate"); // replace schema name
     
        // Set only if empty
        if (expiryDateAttr && !expiryDateAttr.getValue()) {
            var today = new Date();
            today.setDate(today.getDate() + 30); // Add 30 days
     
            expiryDateAttr.setValue(today);
        }
    }
    Notes
    • Replace new_expirydate with the actual schema name
    • Runs only for new records
    • Date is set immediately on the form
     
    Option 2: Power Automate Flow
    Recommended when Invites may be created via Forms, Imports, APIs or Integrations. Works regardless of how the record is created and no dependency on form scripts.

    Steps
    1. Create a Automated Cloud Flow
    2. Trigger: Dataverse → When a row is added
    3. Table: Task (Choose the required table name)
    4. Update the same row and set Due Date (Choose the required field name)

    Expiry Date Expression (30 Days in Future)
    Use this expression in the Update row action:
    addDays(utcNow(), 30)



    Hope this helps.
     
    Thanks!
    Inogic

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 Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 118 Super User 2026 Season 1

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 46 Most Valuable Professional

#3
NeerajPawar Profile Picture

NeerajPawar 41

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans