0

I created custom actions from ribbon via this article - Deploying Custom Action to specific lists in SharePoint 2010 - which works fine.

But when I created a new project I copied from my last project and forgot to change path for the JS file, and deployed the project.

var scriptlink = site.UserCustomActions.Add(); scriptlink.Location = "ScriptLink"; scriptlink.ScriptSrc = "/_layouts/15/SharePointProject2/JavaScript2.js"; scriptlink.Update(); 

Now if I correct the path to the JS file SharePoint still tries to loads the script from the old path.

I have tried reseting IIS, but still SP gets the wrong file.

What can I do in future when I have that problem? I assume it is some cache but I don't know what delete and where.

I use SP2013 and VS 2013

1 Answer 1

0

Try this(CSOM):

static void Main(string[] args) { string siteUrl = "http://sp:12001"; ClientContext clientContext = new ClientContext(siteUrl); Web site = clientContext.Web; UserCustomActionCollection collUCA = site.UserCustomActions; clientContext.Load(collUCA, cas => cas.Where(ca => ca.Title == "myScript")); clientContext.ExecuteQuery(); if(collUCA.Count<1){ UserCustomAction scriptlink = collUCA.Add(); scriptlink.Location = "ScriptLink"; scriptlink.Title = "myScript"; scriptlink.ScriptSrc = "/_layouts/15/js/JavaScript1.js"; scriptlink.Update(); clientContext.ExecuteQuery(); } else { UserCustomAction scriptlink = collUCA.First(); scriptlink.ScriptSrc = "/_layouts/15/js/JavaScript2.js"; scriptlink.Update(); clientContext.ExecuteQuery(); } Console.WriteLine("done"); Console.ReadKey(); } 
1
  • Thanks for reply, but i deploy it as site features so with my knowledge i dont know how in this case use your code. But finally i found mistake - i can't use this same name of js functions like my another features. Commented Jan 16, 2018 at 13:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.