web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

D365 Portal - Add Button to open web page (like modal)

(0) ShareShare
ReportReport
Posted on by 575

Hi guys

Looking to see if there is a way to add a button to our Portal that opens another page similar to how a modal box would work? We have a form that loads with some data in it but we need to be able to view associated records from this form but the OOB methods aren't working (suspect they are being throttled by the Record ID QueryString).

What I have atm is a form that loads some Score data. Within this form I wish to add 2 buttons - 1 for Application and 1 for Business. If you click on the Application button I would like the Application form data to be rendered in a window (similar to a modal if possible). The same would happen for Business.

I have created all the required Entity Forms and added the relevant QueryString data to the web address. If I use the Create New Record option in the Entity form then it will open a modal but no data is shown even though the web address has the appropriate QueryString data but I suspect this is not being opened as the modal is trying to associate the Score form GUID to a record that it cannot find in the system (as Application is what I want to open in the modal and the web address has the Application GUID in it I'm hoping to open that record but suspect the system is trying to create a new Score record with the Score GUID instead of using the Application GUID).

What I've done is create 3 web pages - 1 has the Score form; 1 has the Application form and the other has the Business form. If I open each page manually (adding the same QueryString  data) then the web form displays as expected.

So what I'm looking to do is to add a couple of buttons (similar to how the Create New Record option works) that will allow these additional web pages to open like a modal. Is there a way to add a couple of buttons to point to these new pages (adding the appropriate GUID data) that opens the web form in a modal?

Hopefully I've explained this well enough and any help appreciated.

Steven

*This post is locked for comments

I have the same question (0)
  • Verified answer
    - Matt Bayes - Profile Picture
    890 on at

    Hey Steven,

    To summarize what you have written above, it sounds like you need a couple buttons that will be used to open related records to the Score entity through N:1 (lookup) relationships.

    If this is the case then you have two options:

    1. Create your own Web Template for the specific page that renders the Score entity form and add an area for your buttons in the liquid code.
      The benefit of this would be that it's very easy to build the buttons because you can use liquid to retrieve the related field data and build the URLs that way.
    2. Create Javascript code to run on the current page you are on to dynamically build the buttons you want and append them to the page. The benefit of this method over #1 would be that you don't have to modify the Page Template - Web Template that's already in place. You would add the code to the page-level and it would render your buttons, setting the URLs on them accordingly.

    With anchors in HTML you can render them as buttons using Bootstrap in the following format:

    <a class="btn btn-primary" href="/somepage" target="_blank">Click Here</a>


    Looking at the tag above, the class is set to render it as a button, and the URL (href) set to some page. The Target attribute controls whether to open in a new window or the existing. Currently, _blank opens in a new window and is handled by the browser, which means Chrome may do something different than Firefox than Edge, etc.

    If you are looking to create a modal dialog/popup to view the related data then you can research how to use Bootstrap modals and render the associated page with the entity form of the record (ie. Application) that you want to show:
    https://getbootstrap.com/docs/4.0/components/modal/

    Without much coding I don't think there are any alternatives to what you require, outside of using a Quick View Form on the Score entity and rendering the Application/Business entities on the Score form itself. If this is easier, than you could potentially build the buttons to hide/show the appropriate sections rather than opening a modal dialog, that way the information would all stay on one page.

    If you have any questions just respond to this post. I hope it was helpful and can assist you going forward.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You can create a custom button and also configure it to redirect to a web page but opening it as a modal would be a tricky bit (which I am not sure :( )

    http://himbap.com/blog/?p=2975

    debajmecrm.com/.../place-custom-button-on-registration-page-in-dynamics-365-portals

    Hope this helps.

  • Steven O'Neill Profile Picture
    575 on at

    Hi Matt/Ravi

    Thanx for the reply. I was able to open the remote page within a modal as I wanted but I couldn't get the sub-grid data to appear for some reason (not entirely sure why). Essentially here is the code I used:

       $('#openApplicationBtn').on('click',function(){

           var dataURL = $(this).attr('data-href') + '?appid=' + $('#new_application').val();

           $('.app-body').load(dataURL,function(){

               $('#openApplication').modal({show:true});

           });

       });

    Ravi, if you wanted to use this method then you would need to alter a few elements in the code to make it work for you specifically but apart from the sub-grid issue everything seemed to work okay with this. I had a few other elements on the page (a modal with the id openApplication; a div within the modal with the class app-body and a button on my page for openApplicationBtn). All worked as expected, except the sub-grid.

    Because of this issue I decided to move away from this as I knew the data was loading into my Entity Form if I accessed the page directly. So I've got a simple piece of code that opens a new Window (with the Entity Form data showing - including the sub-grid) and there is a close button on this page and since it's problematically opened, the script allows me to close the page with no issues. Not the ideal but it works as hoped for. So basically it ended up being a version of what Matt suggested. I knew it could be accomplished this way but was hoping for a sleeker method but just couldn't get it to work as hoped.

    Cheers

    Steven

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Great Steven!!! Thanks for sharing your finding. Something new I learned today :)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans