Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Sunday Validation

Avatar

Level 2

I have 2 date/time fields in a timesheet form.  Currently, users can pick any date they want in the first, and the second populates with a date 6 days later.  I'm not sure how to validate that the day they pick is a Sunday.  Is that possible with scripting??

Thanks in advance,

Rose.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

I created a sample for you ...see the attached file.

paul

View solution in original post

4 Replies

Avatar

Former Community Member

Not without scripting .....you can turn the date chosen into a javascript date object and then there is a js function that will return you the day of the week for that particular date.

Paul

Avatar

Level 2

i dont have a huge knowledge of javascript. could you help me with how to do that?

Avatar

Former Community Member

The attached validates the first date entered is a Sunday and calculates the second date as 6 days from the first date.

// form1.page1.date1::exit - (FormCalc, client)

// Get the number of days since epoch (Jan 1, 1900).

var dateNum = Date2Num($.formattedValue,"MM/DD/YYYY")

// Convert the number of days to the full weekday name.

dayOfWeek.rawValue = Num2Date(dateNum,"EEEE")

// Calculate 6 days from the chosen date by adding 6 to the number of days since the epoch.

date2.rawValue = Num2Date(dateNum+6,"MM/DD/YYYY")

if (dayOfWeek.rawValue ne "Sunday") then

          xfa.host.messageBox("Date1 must be a Sunday.");

endif

Steve

Avatar

Correct answer by
Former Community Member

I created a sample for you ...see the attached file.

paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----