Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Portals PATCHWeb API showing multiple error messages

(0) ShareShare
ReportReport
Posted on by 50

Hi All, 

I am trying to call Portals Web API for updating a record using below function and i have  a plugin in some cases. I tried to capture error in "error" block and portal is showing plugin error in case of plugin exception. However, it is displaying two alerts 

One for Plugin Exception as Alert

One for common data exception error 

Can anyone help in restricting the multiple alerts 

Below is my code 

function updateCRMRecord(recordObj,tablepluralname,id) {
appAjax('Updating Record', {
type: "PATCH",
url: "/_api/"+ tablepluralname+"("+id+")",
contentType: "application/json",
data: JSON.stringify(recordObj),
success: function (res, status, xhr) {
alert('Success');
},
        error:function(res) {
            var err= JSON.stringify(res);
            var err1 = JSON.parse(err);
            alert(err1.responseJSON["error"]["innererror"].message);
            return;
            console.log(res);
        }
});
return false;
}

Can anyone help how can i stop displaying common data services error alert however need to display inner error

I have already enabled inner error site setting 

  • ingu Profile Picture
    ingu 50 on at
    RE: Portals PATCHWeb API showing multiple error messages

    Still i am getting two messages one from plugin exception as alert (working properly) and after i click ok it is again showing common data service error

  • Suggested answer
    Manoj Mane Profile Picture
    Manoj Mane 1,012 on at
    RE: Portals PATCHWeb API showing multiple error messages

    Hi,

    please refer the below code snippet:- 

    CrmCController.addComment = function () {
    debugger;

    var dataToUpdate = {
    "new_comment": CrmCController.currentcomment

    };
    webapi.safeAjax({

    type: "PATCH",
    url: "/_api/new_attendeesdetailses(" + eventAttendeeId + ")",
    contentType: "application/json",
    data: JSON.stringify(dataToUpdate),
    success: function (res, status, xhr) {
    console.log(res);
    window.location.href = '/events';
    // $('#mainBodyContainer').hideLoading();

    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
    alert(XMLHttpRequest.responseJSON.error.innererror.message);

    }
    });
    }

    Thanks,
    Manoj.

    Please mark this as VERIFIED if it helps.

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans