张宇恒
2022-12-23 b4b8a2df1f478030bb321b6ac558f13fbbffbb07
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Submit_For_Approval</fullName>
    <availability>online</availability>
    <displayType>button</displayType>
    <linkType>javascript</linkType>
    <masterLabel>提交待审批</masterLabel>
    <openType>onClickJavaScript</openType>
    <protected>false</protected>
    <url>{!RequireScript(&quot;/soap/ajax/51.0/connection.js&quot;)}
{!RequireScript(&quot;/soap/ajax/51.0/apex.js&quot;)}
{!RequireScript(&quot;/resource/CommonUtilJs&quot;)}
//2021-10-21 gwy 版本更改为51.0
var foo = function() {
if(&apos;{!SolutionProjectRequirements__c.Status__c}&apos; == &apos;07结案&apos;){
alert(&apos;已结案&apos;);
return;
}
if(&apos;{!SolutionProjectRequirements__c.Submit_Date_YouWant__c}&apos; &lt; &apos;{!DATEVALUE( SolutionProjectRequirements__c.CreatedDate +3)}&apos;){
alert(&apos;希望提交日期不得小于三天,如紧急需求请邮件联络Solution担当&apos;);
return;
}
var attachments = sforce.connection.query(&quot;select id,Department_Class__r.OwnerId,Department_Class__r.Owner.SalesManager__c  from Account where id = &apos;{!SolutionProjectRequirements__c.Department_ClassId__c}&apos;&quot;); 
var records= attachments.getArray(&quot;records&quot;);
//alert(records[0].Department_Class__r.OwnerId+&apos;====={!CASESAFEID($User.Id)}&apos;);
//alert(records[0].Department_Class__r.Owner.SalesManager__c +&apos;====={!CASESAFEID($User.Id)}&apos;);
 
var header = &apos;{!SolutionProjectRequirements__c.Product_Leader__c}&apos;;
var usrname = &apos;{!$User.Name__c}&apos;;
var rtn = &apos;&apos;;
rtn = sforce.apex.execute(&quot;SolutionProjectUtil&quot;, &quot;getName&quot;, {header:header,usrname:usrname});
//alert(rtn);
//alert(&apos;{!SolutionProjectRequirements__c.Product_Leader__c}&apos;);
if(records.length &gt; 0){
if(rtn != &apos;Y&apos; &amp;&amp; &apos;{!CASESAFEID($User.Id)}&apos; != records[0].Department_Class__r.OwnerId &amp;&amp; &apos;{!CASESAFEID($User.Id)}&apos; != records[0].Department_Class__r.Owner.SalesManager__c){
alert(&apos;只允其战略科室主担、产品担当及省经理提交solution项目需求!&apos;);
return;
}
}
if (!confirm(&quot;一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?&quot;)) {
return;
}
 
 
//window.$Label = window.$Label || {};
//$Label.customLabel= &apos;{!($Label.ProfileId_SystemAdmin)}&apos;;
//var label = $Label.customLabel;
 
sforce.connection.sessionId = &quot;{!$Api.Session_ID}&quot;;
var isopd = new sforce.SObject(&quot;SolutionProjectRequirements__c&quot;);
isopd.Id = &quot;{!SolutionProjectRequirements__c.Id}&quot;;
isopd.Submint_TF__c = true;
isopd.Submitter__c = &quot;{!$User.Id}&quot;; 
try {
var result = sforce.connection.update([isopd]);
var messages = getConnectDMLErrorMessages(result);
if (messages.length &gt; 0) {
alert(messages.join(&quot;\n&quot;));
return;
}
} catch (err) {
if(err.faultstring !=undefined &amp;&amp; err.faultstring.indexOf(&apos;INVALID_SESSION_ID&apos;) != -1) {
alert(&apos;当前网页已登出,请您重新登录后刷新该网页!&apos;);
} else {
alert(err.faultstring);
}
return;
}
 
window.location.reload();
};
foo();</url>
</WebLink>