- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2024 11:37 PM
Hello,
I have been trying to update the RITM work notes. Somehow, the script did not work. Please help review the code and provide suggestion to fix it. Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2024 11:48 PM - edited 04-14-2024 11:56 PM
Hi Annie, what sort of debugging have you done? Have you checked that the script is actually entering the if-statement? To me it looks like that is your issue. When you look at the Approval field that you're accessing on your RITM within your code, you'll see that the value for the sys_choice "Not Yet Requested" is "not requested". So your script should be comparing that instead.
Also, since your business rule is a before type of business rule, your script should not call .update() within it:
var approvalStatus = current.approval;
if (approvalStatus == "not requested") {
current.work_notes = "This request item has not been reviewed";
}
Also, small PSA, but please try and include code/errors as text in your question, not as images. You can format your code so it's easy to read. When it's included as text, it makes it easier for us to copy your code into our answers. You can see this post for more reasons why it's not a good idea to include code as an image.
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2024 11:48 PM - edited 04-14-2024 11:56 PM
Hi Annie, what sort of debugging have you done? Have you checked that the script is actually entering the if-statement? To me it looks like that is your issue. When you look at the Approval field that you're accessing on your RITM within your code, you'll see that the value for the sys_choice "Not Yet Requested" is "not requested". So your script should be comparing that instead.
Also, since your business rule is a before type of business rule, your script should not call .update() within it:
var approvalStatus = current.approval;
if (approvalStatus == "not requested") {
current.work_notes = "This request item has not been reviewed";
}
Also, small PSA, but please try and include code/errors as text in your question, not as images. You can format your code so it's easy to read. When it's included as text, it makes it easier for us to copy your code into our answers. You can see this post for more reasons why it's not a good idea to include code as an image.
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 12:23 AM
I apologize, Nick for not doing a great job of debugging. I still in the process of learning JavaScript and I did not know what I was doing. Thank you for sharing your experience. It will definitely help me for this learning journey, Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 12:36 AM
Could you please let me know how did you capture the entire code so that I can learn it instead of capturing the code as an image in the near future. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 04:19 AM
No worries 🙂 - Sure, to format your code you can use the Insert/Edit code sample button
Then in the popup select the language (in this case JavaScript), and paste your code (usually it's easier to format outside of the editor before you paste it).