Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Page reload which can display proper webresource upon form Save.

(0) ShareShare
ReportReport
Posted on by 190

Hi,

I am fairly new to CRM and quite not sure if I am doing right.

I have a page with a 2 webresources ( some third party subgrids) which holds the child records. These child records are created upon the form save.

My requirement is to display only one of the subgrids depending on a particular field value upon save.

I have the below function which is triggered onload() which works fine. However the same function does not work onSave(). ie lets say when i open the form which is not the first time created one it works fine. However if i am creating the parent record first time this does not work. Instead it displays empty section.

Please note: The webresource I am using is some thirdparty control that does not support any javascripts so that is why I have placed them in a section.

My code is below:

function DisplayCorrectgrid(executionObj)

{

if(myfieldvalue = "abc")

xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(true);

xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(false);

}

else

{

xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(false);

xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(true);

}

I feel I am doing something wrong in here but quite not sure of how to get this done. Any kind of advice is helpful. Thanks in Advance.

*This post is locked for comments

  • Brekh Profile Picture
    Brekh 190 on at
    RE: Page reload which can display proper webresource upon form Save.

    Hello Hemant,

    Thankyou for constantly responding to my updates. I actually did try putting them in seperate tab but that did not work either. What I notice was upon Save the method from OnLoad event is being called. I figured because I added an alert in the method from the OnLoad event and it is getting called from my method which is called on change event of ModifiedOn, but ofcourse grid still does not show any data.:(

    Also, it was typo that I was using '=' instead of '=='. Thanks for checking the minute details though.

    Brekh

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Page reload which can display proper webresource upon form Save.

    Hi Brekh,

    Not sure what would issue there, I would suggest keep that sub-grid in a seprate tab and give a try.

    An one more thing I have observed in your code:

    Your code:

    function DisplayCorrectgrid(executionObj)

    {

    ///This should be changed

    if(myfieldvalue = "abc")

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(true);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(false);

    //Please change above 

    if(myfieldvalue == "abc"){

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(true);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(false);

    }

    }

    else

    {

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(false);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(true);

    }

    Thanks

    Hemant Sahu

  • Brekh Profile Picture
    Brekh 190 on at
    RE: Page reload which can display proper webresource upon form Save.

    Oops...sorry if my problem was not stated clearly earlier. I actually mentioned in my original post that I have a subgrid in each of the sections and that is a 3rd party subgrid which does not support any javascripts.

    So I was trying to do show hide through sections. Thanks for your time looking into the problem and if you can suggest me anything I can give a try.

  • Shantnu Sharma Profile Picture
    Shantnu Sharma 655 on at
    RE: Page reload which can display proper webresource upon form Save.

    Your problem is - You are able to see the section but the grid on the section is empty? If that is the case, the code segment that is pasted here and the way question has been framed, it is misleading. What people here are suggesting for is that you don't see the section and hence the sub-grid.

  • Brekh Profile Picture
    Brekh 190 on at
    RE: Page reload which can display proper webresource upon form Save.

    Hi Shantnu,

    I did try putting some alerts to see if my new method is being called. and yes it is calling and myfieldvalue has some data.

    However, I think as the childrecords for that subgrid are created through plugin I believe it is not functioning and only empty grid is reloaded.

    Thanks.

  • Shantnu Sharma Profile Picture
    Shantnu Sharma 655 on at
    RE: Page reload which can display proper webresource upon form Save.

    Brekh - Let us change our approach here. Put an alert(myfieldvalue) to see what is your variable's value or if your code is being called properly or not. Check it's value on create form and update form as well. Share your results.

  • Brekh Profile Picture
    Brekh 190 on at
    RE: Page reload which can display proper webresource upon form Save.

    Hello Hemant,

    I implemented a new method which does the same as mentioned above and called it upon ModifiedOn change event but still no luck.

    Thanks

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Page reload which can display proper webresource upon form Save.

    Hi Brekh,

    I got the your problem,So need to execute the above code after save.

    As we dont have AfterSave event but still we can achieve that, so you can create a method and call on change of ModifiedOn field .Once you perform save operation ModifiedOn field value will be changed so method will be triggred.

    function onAfterSave()

    {

    if(myfieldvalue = "abc")

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(true);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(false);

    }

    else

    {

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(false);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(true);

    }

    Call the above method on modifiedon field change.This will work for sure.

    Thanks

    Hemant Sahu

  • Brekh Profile Picture
    Brekh 190 on at
    RE: Page reload which can display proper webresource upon form Save.

    Hi Hemant,

    Thanks for the reply. This is what I am trying to do, I am calling the below javascript method on OnLoad() of an OpptyAcct form ( which is a quickCreate form). Based on my field values from the OpptyAcct form, I am displaying either of ABCsection or XYZsection where each section has a subgrid.

    where subgrid data is created only upon save of my OpptyAcct through Plugin. so I basically need to refresh the page so that proper grid is displayed upon save of OpptyAcct.

    function DisplayCorrectgrid(executionObj)

    {

    if(myfieldvalue = "abc")

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(true);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(false);

    }

    else

    {

    xrm.page.ui.tabs.get("subgrid_tab").section.get("abcsection").setVisible(false);

    xrm.page.ui.tabs.get("subgrid_tab").section.get("xyzsection").setVisible(true);

    }

    So this is working if I try to open the OpptyAcct from the Opportunity form but when i try to create a new OpptyAcct above method from Save does not work. No error but it just does nothing.

    Thanks.

  • Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Page reload which can display proper webresource upon form Save.

    Brekh,

    If possible then please share the details of error if you are getting any error.

    Could you please share the more details how you are calling methods.

    Thanks

    Hemant Sahu

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

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... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans