Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Need to cancel particular record or fetch subgrid row id.

Posted on by Microsoft Employee

I have a subgrid of case on contact ehtity and i want to cancel the particular row of this grid on selection , so how can i use achieve this task. i have already put custom button using ribbon workbench and i want to cancel this subgrid row on selection

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need to cancel particular record or fetch subgrid row id.

    i fetched the guid sir, thank you.

    Now how can i cancel it with button, as i click on button it should cancel the selected record, 

    i m using ribbon work bench, but coult not do it. and it takes lot of time to publish.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Need to cancel particular record or fetch subgrid row id.

    Hi,

    The links I shared above has the code snippet for getting the selected row and id.
    Extract from the link-
    -------------
    //Get an array of entity references for all selected rows in the subgrid
    var selectedEntityReferences = [];
    var selectedRows = Xrm.Page.getControl("Contacts").getGrid().getSelectedRows();
    selectedRows.forEach(function (selectedRow, i) {
     selectedEntityReferences.push(selectedRow.getData().getEntity().getEntityReference());
    });
    ---------------

    You need to work out how to change this as per your requirement. I would suggest go with the basics by
    1) Writing the JS code to select the the row guid and displaying alert for it.
    2) Use rest builder to get the JS code to cancel the case by hard coding the guid
    3) Then merge the above two code i.e. get the guid from the (1) and then pass it on (2).  

    Regarding Rest builder, it is very easy to use. You need to
    1) download & install the managed solution. Once it is installed, it will appear when you navigate to Settings >> Solutions >> {as the command bar button at top named 'CRM Rest Builder'} (it not refresh the page).
    2) Click on the button, this will open the tool.
    3) There you select the values as per the below screenshot [Web API, Update, ID of teh case to update etc) and click Create request.
    4) When you click on create request, you will get the exact code to be used. (You then later need to update the pass the GUid as parameter instead if hard coding)
    5) You can also click Execute request which will execute the request and cancel the case you have selected the guid for.

    restbuildercancelcase1.png

    restbuildercancelcase1.png

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need to cancel particular record or fetch subgrid row id.

    Can you send js code for subgrid and guid how use restbuilder?

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Need to cancel particular record or fetch subgrid row id.

    Hi,

    You will need to use javascript to get the selected row from the subgrid and then a WEBAPI request to update the case status to cancel.

    Refer below link for JavaScript method to get the selected row from subgrid-

    msdn.microsoft.com/.../dn932126.aspx

    For WEBAPI, you can download & use CRM Rest Builder tool-

    github.com/.../CRMRESTBuilder

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need to cancel particular record or fetch subgrid row id.

    Thanks for the reply sir, but it does not solve my problem because i need to store cancel in that case going into case entity .

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Need to cancel particular record or fetch subgrid row id.

    Hi,

    If by cancel you mean delete then you don't need to do anything. By default, you get the option (little delete icon on mouse hover) to delete the sub grid row (based on security roles though).

    If you want to retrieve the selected row on the sub grid, you can refer this link which lists all the supported method for subgrids.

    msdn.microsoft.com/.../dn932126.aspx

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans