SBX - Search With Button

SBX - Forum Post Title

SL 2015 WebApps Unlink Attachment

Microsoft Dynamics SL Forum

Mark E asked a question on 5 Apr 2019 12:52 PM
My Badges

Question Status

Verified

Seems that in WebApps Expense Reports, a user is able to Unlink an attachment even if the Expense report is Completed/Posted.  We want to only allow the Unlink button to appear if the Expense Report is "In Process".  I can find references to the Unlink button in the Attachments.vbhtml file in the Source code, but not sure how to add the condition of hiding/disabling the button based on the Expense Report status.

Thanks.

Reply
Marc D responded on 5 Apr 2019 1:51 PM
My Badges

Hey Mark -

I haven't worked too much with expense, but you could try one of these 2 options...

1. the Attachment.vbhtml file uses ViewData("ReadOnly") and if True, the button is not shown; so you could force the ViewData("ReadOnly") to be True in your controller

2. the Unlink button has an id of "unlinkPop"; write JavaScript in ExpenseGrid.vbhtml to disable it if status != 'In Process' - the disabling would be something like:  $('#unlinkPop').addClass('ui-disabled');  or just hide it using $('#unlinkPop').hide();   could tie to the button click that opens the Attachment with a test on status.

Again, haven't tested either, but that's where I'd start.

Good luck!

Marc

Reply
Marc D responded on 5 Apr 2019 2:23 PM
My Badges

Actually...try this

add to your DetailAttachment.vbhtml

   $(document).ready(function () {

       if ($("#All").css('visibility') != "hidden") {

           $('#unlinkPop').hide();

       }

       else {

           $('#unlinkPop').show();

       }

   });

Reply
Mark E responded on 5 Apr 2019 4:59 PM
My Badges

Marc,

Thanks, trying to determine where exactly in the vbhtml you are suggesting this code, within the AttachmentUnlink function, or somewhere else?

Also, this would be on the HeaderAttachment.vbhtml, as we have suppressed the ability for users to link attachments for grid entries, and only allowing attachments at the Document level.

Reply
Marc D responded on 5 Apr 2019 5:05 PM
My Badges
Verified Answer

Ah...sorry, i assumed detail note.

Yes, put in the HeaderAttachment.vbhtml in the <script> element

Reply
Mark E responded on 5 Apr 2019 5:42 PM
My Badges

Works great, thanks!!

Reply
Marc D responded on 5 Apr 2019 5:05 PM
My Badges
Verified Answer

Ah...sorry, i assumed detail note.

Yes, put in the HeaderAttachment.vbhtml in the <script> element

Reply

SBX - Two Col Forum

SBX - Migrated JS