Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Issue with formContex.data.save

(0) ShareShare
ReportReport
Posted on by 5

Context:

So on a form, I have a setup a OnLoad event via the form editor(the OnLoadEvent is called "pits.UserReport.OnFormLoad"). I have create a custom ribbon button called "Submit Report", and made it visible to all statuscode but "Submitted" and "Approved". The form statuscode defaults to "New", then when it is saved there is a plugin that set the statuscode to "Saved"

When a user hit the "Submit Report" button , the form should save(if it is new or dirt) then make a custom api call. I having this weird error that whenever I click the button I get this error:

Web resource method does not exist: pits.UserReport.OnFormLoad. However the closest object we found is pits that contains these properties: userReportRibbon,quoteRibbon. Please verify this object is not corrupt and is not an object of the same name defined elsewhere, such as another script.Session Id: 83aaf2bb-2d7c-4406-bc50-a9c778734fb5Correlation Id: d78cf2b6-3f81-4a55-b2ed-cecead8320caEvent Name: onloadFunction Name: pits.UserReport.OnFormLoadWeb Resource Name: pits_FormMainSolution Name: ActivePublisher Name: DefaultPublishercmicrmTime: Fri Mar 25 2022 01:50:41 GMT-0400 (Eastern Daylight Time)

Yeah the whole thing does do what I want in the end, but my end users are going to get very confuse, and some(the ever error throw is the end of world) will see the error and just stop working till no error is throw. It seems like the formContext.data.save() is saving the entity, and trying to refresh the page.

I do know that the method pits.UserReport.OnFormLoad does exist since it work when I first open the form, but not after executing formContext.data.save(). I even tried 

formContext.data.refresh(true) but the error still remains

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Issue with formContex.data.save

    Hi michaeljoye,

    I'm glad to hear that and thanks for sharing your solution.

  • michaeljoye Profile Picture
    michaeljoye 5 on at
    RE: Issue with formContex.data.save

    I was able to resolve this issue. The issue is that pits.UserReport was not in the WebResource as the ribbon button JS. I ended up having to package everything into one js file.

    I had two js files one for ribbon and one for forms.

    Somehow the refresh was just happening in just context of the ribbon js page.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Issue with formContex.data.save

    Hi michaeljoye,

    Usually, this error is caused by the syntax error or you type the wrong function name in onload event. However, you say it work fine on you first load the form. So it shouldn't cause by those. Could you provide your JS code of pits.UserReport.OnFormLoad for further research?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,253 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans