Skip to main content

Notifications

Community site session details

Community site session details

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

Problem with fields with business rules and javascript

(1) ShareShare
ReportReport
Posted on by 448

Hi all

I've 4 custom fields in my crm 
pastedimage1677140813899v1.png

there is a "business rule" that makes data fields mandatory when the bottom left field is set to "yes"; this work well.

With a javascript I would set the data fields at today, below screenshot of event and javascript.

pastedimage1677141400430v2.png

pastedimage1677141507589v3.png

When I set field value on YES, program show this error:

pastedimage1677142809580v5.png
Can someone help me to find where I'm mistaken?

Thans in advance

  • DiePic Profile Picture
    448 on at
    RE: Problem with fields with business rules and javascript

    Hi a33ik 

    thank you very much ... you are the real guru :-) ... now works.


    here the script if it can help someone.


    pastedimage1677164167414v1.png

  • Verified answer
    a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Problem with fields with business rules and javascript

    Then replace TRsn === 1 with just TRsn and TRsn === 0 with !TRsn.

  • DiePic Profile Picture
    448 on at
    RE: Problem with fields with business rules and javascript

    Hi a33ik 

    1st (ath_tacitorinnovosino) is boolean (yes/no), all the others are date

    pastedimage1677161700811v1.png

  • Suggested answer
    a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Problem with fields with business rules and javascript

    Those fields:

    pastedimage1677158319079v1.png

    Are those datetimes, whole number, string, optionset, booleans? One by one, please.

  • DiePic Profile Picture
    448 on at
    RE: Problem with fields with business rules and javascript

    Hi a33ik 

    pastedimage1677157941173v1.png

    as you have for sure understood, I'm not so good with javascript and its concepts ... how can I do that?

  • a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Problem with fields with business rules and javascript

    Ok. Can you provide types of fields you're getting using getValue?

  • DiePic Profile Picture
    448 on at
    RE: Problem with fields with business rules and javascript

    Hi KalpanaNadar 

    with https://jshint.com/ I find some error on brackets ... I'm not so good with javascript and its concepts ... what do you mean with "check if you are passing the executionContext while calling the SetDateToday function"?

  • DiePic Profile Picture
    448 on at
    RE: Problem with fields with business rules and javascript

    Hi a33ik  thanks for link ... very useful tool.

    but after corrections the program not show errors, but dont set the date fields  ...  below the control


    pastedimage1677156483145v2.png

  • KalpanaNadar Profile Picture
    45 on at
    RE: Problem with fields with business rules and javascript

    Hi DIE PIC,

    I would request you to check if you are passing the executionContext while calling the SetDateToday function.

    And also try to edit this code in visual studio and verify all the braces are closed properly and function syntax is correct.

    As the error "Web resource method does not exist" we get only when the function is missing braces or any syntax error in the script and the function is not referenced correctly while calling it.

  • Suggested answer
    a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Problem with fields with business rules and javascript

    Ok. Now I see what is happening. Your code is invalid. Check the following lines:

    pastedimage1677154433447v1.png

    you don't have the closing bracket.

    pastedimage1677154461539v2.png

    and here

    pastedimage1677154478841v3.png

    and there

    pastedimage1677154492106v4.png

    and even there

    One more thing:

    pastedimage1677154513727v5.png

    you have try, you don't have catch.

    I would recommend to check your code for syntax errors here - https://jshint.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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,302 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,114 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans