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 Automate / Web site with Angular ...
Power Automate
Answered

Web site with Angular material calender picker

(1) ShareShare
ReportReport
Posted on by 50
Hi there
 
I trying to use Javascript to inject the date value i.e 23 May 2025 into the website with Angular calendar picker but not working.
The date field is not editable meaning user has to click on the calendar picker to choose the date i.e 23 May 2025.
 
What is the approach to deal with this issue?
The below javascript was used but the date field is not populated.
 
;(function () {
    const ContainerDataTable_JSON = '[["ABCD 4231466", "13 May 2025"], ["ABCD 6906828", "13 May 2025"], ["ABCD 0589449", "13 May 2025"], ["ABCD 1883165", "13 May 2025"]]';

    let ContainerDataTable;
    try {
        ContainerDataTable = JSON.parse(ContainerDataTable_JSON);
    } catch (e) {
        console.error("❌ Failed to parse JSON:", e);
        return;
    }

    if (!Array.isArray(ContainerDataTable)) {
        console.error("❌ Parsed data is not an array:", ContainerDataTable);
        return;
    }

    const containerMap = {};
    ContainerDataTable.forEach(([container, date]) => {
        containerMap[container.trim().toUpperCase()] = date.trim();
    });

    const rows = document.querySelectorAll("tr");

    rows.forEach((row) => {
        const containerCell = row.querySelector("td.cdk-column-containerNumberMasking");

        if (containerCell) {
            const containerNumber = containerCell.textContent.trim().toUpperCase();

            if (containerMap.hasOwnProperty(containerNumber)) {
                const input = row.querySelector("input.mat-datepicker-input");

                if (input) {
                    input.removeAttribute("readonly");
                    input.removeAttribute("disabled");

                    const toggleButton = row.querySelector("button.mat-datepicker-toggle");

                    if (toggleButton) {
                        toggleButton.click();
                        console.log(`📅 Calendar opened via toggle for ${containerNumber}`);
                    } else {
                        input.click();
                        console.log(`📅 Calendar opened via input click for ${containerNumber}`);
                    }

                    const dateValue = containerMap[containerNumber];
                    const dateParts = dateValue.split(" ");
                    const day = parseInt(dateParts[0], 10);
                    const month = dateParts[1];
                    const year = dateParts[2];

                    const validMonthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
                    if (!validMonthNames.includes(month)) {
                        console.error(`❌ Invalid month in date: ${month}`);
                        return;
                    }

                    // ✅ Use standardized format: "DD MMM YYYY"
                    const formattedDateString = `${day.toString().padStart(2, '0')} ${month} ${year}`;

                    setTimeout(() => {
                        const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
                        nativeInputValueSetter.call(input, formattedDateString);

                        input.dispatchEvent(new Event("input", { bubbles: true }));
                        input.dispatchEvent(new Event("change", { bubbles: true }));
                        input.dispatchEvent(new Event("blur", { bubbles: true }));
                        input.dispatchEvent(new Event("focusout", { bubbles: true }));

                        console.log(`✅ Set ${containerNumber} date to ${formattedDateString}`);
                    }, 1000);
                } else {
                    console.warn(`⚠️ Input not found for ${containerNumber}`);
                }
            }
        }
    });
 
 
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at
    A month ago I helped someone have their flow select date in an angular date picker: https://community.powerplatform.com/forums/thread/details/?threadid=40b41ef0-8513-f011-998a-7c1e525a8110

    So simply capture the date, month and year elements and customize them to variables so the flow dynamically selects the correct date. I would recommend to do it this way so with PADs low code actions rather than with JavaScript since this is what PAD excels at and its gonna be easier to manage and modify the low code solution.

    If you really want to do it with javascript then have you tested that it actually works without PAD? So if you put that code into browsers console does it select the dates correctly?
     
  • KO-05050229-0 Profile Picture
    50 on at
     
    For the year i got this error while trying to follow your method:
     
     
    browser calendar UI:
     
  • Suggested answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at
    Hi,

    Can you share a screenshot of your flow. 

    Make sure the year part of the calendar is open when your flow attempts to click the 2026 year.


     So this needs to be visible in your screen when the flow is trying to find the 2026 element:


    What element gives error (is it the last span or some other) if you try to test the selector with the "Test" -feature in the UI selector window (again the year element has to be visible in your screen when you test the selector:

     
  • KO-05050229-0 Profile Picture
    50 on at
     
    the flow screen 
     
     
     
    Test error
     
  • Verified answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at
    Thank you for the clarifying screenshots

    Try changing the operator to be "Contains" instead of equals. It could be that the value is " 2026 " so not exactly "2026" but with spaces around it.
    So change that "Contains" rather than "Equals to"


    If that doesn't work open inspect in your browser (F12) and check what value is in that span

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard