-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSalesforce_Add-ons.user.js
More file actions
59 lines (47 loc) · 2.61 KB
/
Salesforce_Add-ons.user.js
File metadata and controls
59 lines (47 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name Salesforce Add-ons
// @namespace http://csutherl.github.io/
// @version 0.2
// @description Script to add fancy buttons to save me few clicks! The @match only applies to URLs for the case view pages. Also, I am using jquery for the selector, but it isn't necessary as you can do the same thing in plain js; I just wanted to see if includes worked since this is my first userscript :D
// @author coty
// @match https://gss--c.na7.visual.force.com/apex/Case_View*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// @updateURL https://github.com/csutherl/random-userscripts/raw/master/Salesforce_Add-ons.user.js
// ==/UserScript==
// Grab the selector for the block I want to add buttons to
var commentBlockSelector = $("[id^=Page\\:form\\:CaseComment\\:j_id]");
// Append the Waiting on Customer button
commentBlockSelector.append("<input class=\"btn\" id=\"WoCbtn\" type=\"button\" value=\"New WoC Comment\" onclick=\"updateWoC()\"/>");
// this function contains the logic for the WoC button click
function updateWoC() {
$('#newCaseCommentButton').click();
$('#new_status').val("Waiting on Customer");
$('#new_internalStatus').val("Waiting on Customer");
// new sfdc change makes comments public by default
// $('#new_isPublic').click();
}
// add the function code to the <head>
$('<script type="text/javascript">' + updateWoC + '</script>').appendTo($('head'));
// Append the Closed/Closed button
commentBlockSelector.append("<input class=\"btn\" id=\"WoCbtn\" type=\"button\" value=\"New Closed/Closed Comment\" onclick=\"updateClosed()\"/>");
// this function contains the logic for the closed/closed button click
function updateClosed() {
$('#newCaseCommentButton').click();
$('#new_status').val("Closed");
$('#new_internalStatus').val("Closed");
// new sfdc change makes comments public by default
// $('#new_isPublic').click();
}
// add the function code to the <head>
$('<script type="text/javascript">' + updateClosed + '</script>').appendTo($('head'));
// Append the private comment button
commentBlockSelector.append("<input class=\"btn\" id=\"WoCbtn\" type=\"button\" value=\"New Internal Comment\" onclick=\"updateInternal()\"/>");
// this function contains the logic for the private button click
function updateInternal() {
$('#newCaseCommentButton').click();
// new sfdc change makes comments public by default; this will make it private
$('#new_isPublic').click();
}
// add the function code to the <head>
$('<script type="text/javascript">' + updateInternal + '</script>').appendTo($('head'));