3

I have been testing out a JavaScript Custom Action add-in injected a test script into my SharePoint Online master page. During one of the change and deploy cycles this seems to have gone awry as a previous version of my Script Action has gone rogue (One!). I can't remove this older Script Action which means the script.js fires always, regardless of if I add or remove the current version of the Add-in

   • [ScriptLink] {41d1c22d-9b4e-4eb9-aaa4-ed66683e938b} ScriptSrc=null Sequence=0

Any ideas how to nuke this instance please?

2

probably needs improving but can help in stressful situations

you can adapt the match as per your situation

    public void DeleteUserAction()
    {
        context = new ClientContext("http://contoso.com");
        context.Credentials = new System.Net.NetworkCredential("user", "pwd", "dom");
        Web web = context.Web;

        context.Load(web, x => x.UserCustomActions);
        context.ExecuteQuery();

        List<UserCustomAction> ualist = new List<UserCustomAction>();
        foreach (var ca in web.UserCustomActions)
        {
            if (ca.ScriptSrc != null && ca.ScriptSrc.Contains("tweakviews.js"))
            {
                ualist.Add(ca);
            }
        }

        foreach (var aa in ualist)
        {
            aa.DeleteObject();
        }

        context.ExecuteQuery();
    }
  • 1
    Thanks very much , I might covert your CSOM code to PowerShell for quickness, I think that should work. Luckily I test on a Developer Site and not our main intranet ;-) – westerdaled May 10 '17 at 10:05
  • 1
    Thanks so much... as you helped me focus $scriptActions = Get-PnPCustomAction -Scope web $scriptActions[0].Id Guid ---- 41d1c22d-9b4e-4eb9-aaa4-ed66683e938b $scriptActions[0].ScriptSrc $scriptActions[0].DeleteObject() – westerdaled May 10 '17 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.