SPFX - Hide "Submit for Approval" Button

Avery Kirkham 1 Reputation point
2020-11-27T17:02:37.907+00:00

I'm working on an SPFX extension with the intent of hiding the Submit for Approval button that appears in libraries when content approval is enabled (see below), but I'm having trouble getting it to work properly.

43318-capture.png

I have a snippet of TS code set up as below, but it works kind of inconsistently, e.g. usually it hides when the item is clicked, but then if you de-select the item the screen goes white, sometimes the screen goes white when the page loads up, and sometimes nothing happens at all.
For context, all tests so far have taken place in a gulp serve local environment.

43365-image.png

Any ideas as to what I could be doing wrong?
Thanks in advance for any suggestions.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ZhengyuGuo 10,591 Reputation points Moderator
    2020-11-30T07:00:25.3+00:00

    Hi @Avery Kirkham ,

    Try to use setTimeOut to delay trigger the onListViewUpdated function, because the command actions were rendered after this function, please check the code snippet in attachment file:

    43519-code.txt

    43565-snipaste-2020-11-30-14-55-38.png

    Reference:

    How to control command visibility in response to "external" conditions

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Ali Choudhry 1 Reputation point
    2020-12-01T19:02:17.437+00:00

    Use the code under pageLoad() function

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.