From a8b723c94c8a9569ad565878d23434d6a56bebe8 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期五, 14 四月 2023 17:58:55 +0800
Subject: [PATCH] 修改按钮4.14
---
force-app/main/default/lwc/lexCancelReport/lexCancelReport.js | 116 ++
force-app/main/default/classes/OpportunityLightingButtonController.cls | 192 +++
force-app/main/default/lwc/lexLoseReport/lexLoseReport.html | 6
force-app/main/default/lwc/lexCancelReport/lexCancelReport.css | 10
force-app/main/default/lwc/lexLoseReport/lexLoseReport.js | 102 ++
force-app/main/default/lwc/lexLoseReport/__tests__/lexLoseReport.test.js | 25
force-app/main/default/lwc/lexQuotationProductNew/__tests__/lexQuotationProductNew.test.js | 25
force-app/main/default/lwc/lexCancelReport/__tests__/lexCancelReport.test.js | 25
force-app/main/default/staticresources/connection20.resource-meta.xml | 5
force-app/main/default/staticresources/connection20.js | 1935 ++++++++++++++++++++++++++++++++++++++
force-app/main/default/lwc/lexQuotationRequest/__tests__/lexQuotationRequest.test.js | 25
force-app/main/default/lwc/lexCancelReport/lexCancelReport.html | 6
force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js | 73 +
force-app/main/default/lwc/lexLoseReport/lexLoseReport.css | 10
force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js-meta.xml | 11
force-app/main/default/lwc/lexStockApply/lexStockApply.css | 10
force-app/main/default/lwc/lexCancelReport/lexCancelReport.js-meta.xml | 11
force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js | 67 +
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html | 11
force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js-meta.xml | 11
force-app/main/default/lwc/lexStockApply/__tests__/lexStockApply.test.js | 25
force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.html | 14
force-app/main/default/lwc/lexLoseReport/lexLoseReport.js-meta.xml | 11
force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.html | 6
force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.css | 10
force-app/main/default/lwc/lexStockApply/lexStockApply.js | 114 ++
force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js | 103 +
force-app/main/default/lwc/lexStockApply/lexStockApply.html | 6
force-app/main/default/lwc/lexStockApply/lexStockApply.js-meta.xml | 11
29 files changed, 2,932 insertions(+), 44 deletions(-)
diff --git a/force-app/main/default/classes/OpportunityLightingButtonController.cls b/force-app/main/default/classes/OpportunityLightingButtonController.cls
index 9af0a4a..5c0b778 100644
--- a/force-app/main/default/classes/OpportunityLightingButtonController.cls
+++ b/force-app/main/default/classes/OpportunityLightingButtonController.cls
@@ -4,7 +4,7 @@
* @Author: chen jing wu
* @Date: 2023-04-12 11:16:07
* @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-13 17:50:20
+ * @LastEditTime: 2023-04-14 17:24:54
*/
public with sharing class OpportunityLightingButtonController {
@AuraEnabled
@@ -184,6 +184,127 @@
return res;
}
@AuraEnabled
+ public static InitData initForCancelReportButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opportunity = [
+ select
+ StageName,
+ SAP_Send_OK__c,
+ Cnt_Lost_cancel_report__c,
+ Cnt_Lost_cancel_Draft__c,
+ Job_category__c,
+ Bidding_Project_Name_Bid__c,
+ Name,
+ Sales_assistant_name__c,
+ Sales_assistant_ID__c,
+ Manager_name__c,
+ Sales_manager_departmentID__c,
+ Sales_owner_buchang__c,
+ Sales_owner_buchangID__c
+ from Opportunity where Id =: recordId
+ ];
+ res.stageName = opportunity.StageName;
+ res.sapSendOK = opportunity.SAP_Send_OK__c;
+ res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c;
+ res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c;
+ res.jobCategory = opportunity.Job_category__c;
+ res.biddingProjectNameBid = opportunity.Bidding_Project_Name_Bid__c;
+ res.name = opportunity.Name;
+ res.salesAssistantName = opportunity.Sales_assistant_name__c;
+ res.salesAssistantID = opportunity.Sales_assistant_ID__c;
+ res.managerName = opportunity.Manager_name__c;
+ res.salesManagerDepartmentID = opportunity.Sales_manager_departmentID__c;
+ res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c;
+ res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForLostReportButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opportunity = [
+ select
+ StageName,
+ SAP_Send_OK__c,
+ Cnt_Lost_cancel_report__c,
+ Name,
+ Sales_assistant_name__c,
+ Sales_assistant_ID__c,
+ Manager_name__c,
+ Sales_manager_departmentID__c,
+ Sales_owner_buchang__c,
+ Sales_owner_buchangID__c
+ from Opportunity where Id =: recordId
+ ];
+ res.stageName = opportunity.StageName;
+ res.sapSendOK = opportunity.SAP_Send_OK__c;
+ res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c;
+ res.name = opportunity.Name;
+ res.salesAssistantName = opportunity.Sales_assistant_name__c;
+ res.salesAssistantID = opportunity.Sales_assistant_ID__c;
+ res.managerName = opportunity.Manager_name__c;
+ res.salesManagerDepartmentID = opportunity.Sales_manager_departmentID__c;
+ res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c;
+ res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForQuotationRequestButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opportunity = [
+ select
+ Bidding_Project_Name_Bid__r.Id,
+ Estimation_Id__c
+ from Opportunity where Id =: recordId
+ ];
+ res.biddingProjectNameBidId = opportunity.Bidding_Project_Name_Bid__r.Id;
+ res.estimationId = opportunity.Estimation_Id__c;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForStockApplyButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opportunity = [
+ select
+ Stock_apply_status__c,
+ Last_opportunity_file__r.Id
+ from Opportunity where Id =: recordId
+ ];
+ res.stockApplyStatus = opportunity.Stock_apply_status__c;
+ res.lastOpportunityFileId = opportunity.Last_opportunity_file__r.Id;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
+ public static InitData initForQuotationProductNewButton(String recordId){
+ InitData res = new InitData();
+ try {
+ Opportunity opportunity = [
+ select
+ CurrencyIsoCode
+ from Opportunity where Id =: recordId
+ ];
+ res.currencyIsoCode = opportunity.CurrencyIsoCode;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ return res;
+ }
+ @AuraEnabled
public static string updateForAgencyAuthorizeButton(String recordId){
try {
Opportunity opp = new Opportunity();
@@ -222,6 +343,25 @@
opp.ConfirmationofAward__c = LightingButtonConstant.OPPORTUNITY_CONFIRMATION_OF_AWARD_OLY_WIN_BID;
if (opp.Closing_Bid_Date__c == null) {
opp.Closing_Bid_Date__c = Date.today();
+ }
+ update opp;
+ return null;
+ } catch (Exception e) {
+ String eMessage = e.getMessage();
+ Integer left = eMessage.indexOf(',') + 1;
+ Integer right = eMessage.length();
+ return eMessage.substring(left,right);
+ }
+ }
+ @AuraEnabled
+ public static string updateForStockApplyButton(String recordId,Boolean flag){
+ try {
+ Opportunity opp = new Opportunity();
+ opp.Id = recordId;
+ if(flag){
+ opp.Stock_apply_status__c = '濉啓瀹屾瘯';
+ }else {
+ opp.Stock_apply_status__c = '鑽夋涓�';
}
update opp;
return null;
@@ -272,6 +412,36 @@
System.debug('e:****' + e);
}
return tasks;
+ }
+ @AuraEnabled
+ public static List<Tender_Opportunity_Link__c> queryForCancelReportButton(String recordId){
+ List<Tender_Opportunity_Link__c> links = null;
+ try {
+ links = [
+ select id,
+ Tender_information__r.subInfoType__c
+ from Tender_Opportunity_Link__c
+ where (Tender_information__r.subInfoType__c = '3-1锛氬簾鏍囧叕鍛�' OR Tender_information__r.subInfoType__c ='3-2锛氭祦鏍囧叕鍛�') and Opportunity__c =: recordId
+ ];
+ } catch (Exception e) {
+ System.debug('e:****' + e);
+ }
+ return links;
+ }
+ @AuraEnabled
+ public static List<QuoteIrai__c > queryForQuotationRequestButton(String recordId){
+ List<QuoteIrai__c> quotes = null;
+ try {
+ String opportunityId = '%' + recordId + '%';
+ quotes = [
+ select
+ id
+ from QuoteIrai__c where Note__c like :opportunityId and QuoteIrai_Status__c = '鑽夋涓�'
+ ];
+ } catch (Exception e) {
+ System.debug('e:****' + e);
+ }
+ return quotes;
}
public class InitData{
@AuraEnabled
@@ -330,5 +500,25 @@
public String salesAssistantName;
@AuraEnabled
public String salesAssistantID;
+ @AuraEnabled
+ public String jobCategory;
+ @AuraEnabled
+ public String biddingProjectNameBid;
+ @AuraEnabled
+ public String managerName;
+ @AuraEnabled
+ public String salesManagerDepartmentID;
+ @AuraEnabled
+ public String salesOwnerBuchang;
+ @AuraEnabled
+ public String salesOwnerBuchangID;
+ @AuraEnabled
+ public String biddingProjectNameBidId;
+ @AuraEnabled
+ public String stockApplyStatus;
+ @AuraEnabled
+ public String lastOpportunityFileId;
+ @AuraEnabled
+ public String currencyIsoCode;
}
}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html b/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html
index d0f5bfb..159518b 100644
--- a/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html
+++ b/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.html
@@ -1,6 +1,15 @@
+<!--
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-13 15:08:43
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 14:13:25
+-->
<template>
<div class="lexBeforeOPDPDFBtnHolder" if:true={IsLoading}>
<lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
- <lightning-button label="Show Toast" onclick={showSuccess}></lightning-button>
+ <lightning-button label="Show Toast" onclick={showToast}></lightning-button>
+ <lightning-button onclick={handleConfirmClick} label="Open Confirm Modal"></lightning-button>
</div>
</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js b/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js
index e1ba4a1..babbb46 100644
--- a/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js
+++ b/force-app/main/default/lwc/lexBeforeOPDPDFBtn/lexBeforeOPDPDFBtn.js
@@ -1,3 +1,11 @@
+/*
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-13 15:08:43
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 15:37:35
+ */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
@@ -5,7 +13,7 @@
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import selectCommonSequence from '@salesforce/apex/ControllerUtil.selectCommonSequence';
import addReportOPWithEvaluationPDF from '@salesforce/apex/Add_Report.addReportOPWithEvaluationPDF';
-
+import LightningConfirm from 'lightning/confirm';
export default class LexBeforeOPDPDFBtn extends LightningElement {
@api recordId;
accountId;
@@ -36,47 +44,7 @@
})
}
beforeOPDPDFBtn(){
- if (window.confirm('鏄惁鏂板缓OPD鎶ュ憡涔︼紵\n[纭畾] => 鏂板缓OPD\n[鍙栨秷] => 鍙敓鎴� 锛讳骇鍝佽瘯鐢ㄨ瘎浠凤冀')) {
- try {
- selectCommonSequence({
- valueField: 'EvaluationPDF_NextValue__c',
- formatField: 'EvaluationPDF_Format__c'
- }).then(result=>{
- var pdfno = result;
- addReportOPWithEvaluationPDF({
- "repOwnerId": this.userId,
- "reportId": "",
- "dailyReportId": "",
- "eventId": "",
- "recordType": "OPD",
- "aId": this.accountId,
- "visitor1": "",
- "visitor2": "",
- "visitor3": "",
- "visitor4": "",
- "visitor5": "",
- "opp1": this.recordId,
- "opp2": "",
- "opp3": "",
- "opp4": "",
- "opp5": "",
- "reportDate": "",
- "evaluationPDFNumber": pdfno
- }).then(()=>{
- // 20220913 ljh WLIG-CHMATN update end
- this.IsLoading = false;
- window.open('/apex/BeforeOPDPDF?oid=' + this.recordId + '&pdfNo=' + pdfno, 'BeforeOPDPDF');
- this.dispatchEvent(new CloseActionScreenEvent());
- })
- });
- } catch(e) {
- this.showToast(e,"error");
- this.dispatchEvent(new CloseActionScreenEvent());
- }
- } else {
- window.open('/apex/BeforeOPDPDF?oid=' + this.recordId, 'BeforeOPDPDF');
- this.dispatchEvent(new CloseActionScreenEvent());
- }
+ this.handleConfirmClick('鏄惁鏂板缓OPD鎶ュ憡涔︼紵\n[纭畾] => 鏂板缓OPD\n[鍙栨秷] => 鍙敓鎴� 锛讳骇鍝佽瘯鐢ㄨ瘎浠凤冀');
}
showToast(msg,type) {
const event = new ShowToastEvent({
@@ -86,4 +54,55 @@
});
this.dispatchEvent(event);
}
+
+
+ async handleConfirmClick(msg) {
+ const result = await LightningConfirm.open({
+ message: msg,
+ variant: 'headerless',
+ label: 'this is the aria-label value',
+ });
+ console.log(result);
+ if(result){
+ try {
+ selectCommonSequence({
+ valueField: 'EvaluationPDF_NextValue__c',
+ formatField: 'EvaluationPDF_Format__c'
+ }).then(result=>{
+ var pdfno = result;
+ addReportOPWithEvaluationPDF({
+ "repOwnerId": this.userId,
+ "reportId": "",
+ "dailyReportId": "",
+ "eventId": "",
+ "recordType": "OPD",
+ "aId": this.accountId,
+ "visitor1": "",
+ "visitor2": "",
+ "visitor3": "",
+ "visitor4": "",
+ "visitor5": "",
+ "opp1": this.recordId,
+ "opp2": "",
+ "opp3": "",
+ "opp4": "",
+ "opp5": "",
+ "reportDate": "",
+ "evaluationPDFNumber": pdfno
+ }).then(()=>{
+ // 20220913 ljh WLIG-CHMATN update end
+ this.IsLoading = false;
+ window.open('/apex/BeforeOPDPDF?oid=' + this.recordId + '&pdfNo=' + pdfno, 'BeforeOPDPDF');
+ this.dispatchEvent(new CloseActionScreenEvent());
+ })
+ });
+ } catch(e) {
+ this.showToast(e,"error");
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ }else{
+ window.open('/apex/BeforeOPDPDF?oid=' + this.recordId, 'BeforeOPDPDF');
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ }
}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelReport/__tests__/lexCancelReport.test.js b/force-app/main/default/lwc/lexCancelReport/__tests__/lexCancelReport.test.js
new file mode 100644
index 0000000..7171af0
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelReport/__tests__/lexCancelReport.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexCancelReport from 'c/lexCancelReport';
+
+describe('c-lex-cancel-report', () => {
+ afterEach(() => {
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
+ while (document.body.firstChild) {
+ document.body.removeChild(document.body.firstChild);
+ }
+ });
+
+ it('TODO: test case generated by CLI command, please fill in test logic', () => {
+ // Arrange
+ const element = createElement('c-lex-cancel-report', {
+ is: LexCancelReport
+ });
+
+ // Act
+ document.body.appendChild(element);
+
+ // Assert
+ // const div = element.shadowRoot.querySelector('div');
+ expect(1).toBe(1);
+ });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelReport/lexCancelReport.css b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.css
new file mode 100644
index 0000000..a8fa542
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.css
@@ -0,0 +1,10 @@
+.cancelReportHolder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+.container .uiContainerManager{
+ display: none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelReport/lexCancelReport.html b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.html
new file mode 100644
index 0000000..c738dca
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.html
@@ -0,0 +1,6 @@
+<template>
+ <div class="cancelReportHolder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js
new file mode 100644
index 0000000..0032022
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js
@@ -0,0 +1,116 @@
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import init from '@salesforce/apex/OpportunityLightingButtonController.initForCancelReportButton';
+import queryForCancelReportButton from '@salesforce/apex/OpportunityLightingButtonController.queryForCancelReportButton';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+export default class LexCancelReport extends LightningElement {
+ @api recordId;
+ stageName;
+ sapSendOK;
+ cntLostCancelReport;
+ cntLostCancelDraft;
+ jobCategory;
+ biddingProjectNameBid;
+ name;
+ salesAssistantName;
+ salesAssistantID;
+ managerName;
+ salesManagerDepartmentID;
+ salesOwnerBuchang;
+ salesOwnerBuchangID;
+ IsLoading = true;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ console.log(111);
+ console.log(currentPageReference);
+
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ console.log("str");
+ console.log(str);
+ this.recordId = str;
+ }
+ }
+ }
+ connectedCallback(){
+ init({
+ recordId: this.recordId
+ }).then(result=>{
+ this.stageName = result.stageName;
+ this.sapSendOK = result.sapSendOK;
+ this.cntLostCancelDraft = result.cntLostCancelDraft;
+ this.cntLostCancelReport = result.cntLostCancelReport;
+ this.jobCategory = result.jobCategory;
+ this.biddingProjectNameBid = result.biddingProjectNameBid;
+ this.name = result.name;
+ this.salesAssistantID = result.salesAssistantID;
+ this.salesAssistantName = result.salesAssistantName;
+ this.managerName = result.managerName;
+ this.salesManagerDepartmentID = result.salesManagerDepartmentID;
+ this.salesOwnerBuchang = result.salesOwnerBuchang;
+ this.salesOwnerBuchangID = result.salesOwnerBuchangID;
+ this.cancelReport();
+ })
+ }
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ }
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+ cancelReport(){
+ //XLIU-CG98L5 銆愬鎵樸�戙�愯瘎浼般�戞柊闇�姹�-鎷涙爣椤圭洰/璇环瀵瑰簲娴佹爣銆佸簾鏍囨敼鍠� start
+ queryForCancelReportButton({
+ recordId: this.recordId
+ }).then(result=>{
+ var sqlResult = result;
+ // alert('娴嬭瘯+锛�'+sqlResult.size);
+ //XLIU-CG98L5 銆愬鎵樸�戙�愯瘎浼般�戞柊闇�姹�-鎷涙爣椤圭洰/璇环瀵瑰簲娴佹爣銆佸簾鏍囨敼鍠� end
+ // js銇牬鍚堛�佺炕瑷炽仌銈屻仧鍊ゃ亴銇с倠銇仹銆佽娉ㄦ剰
+ if (this.stageName != '寮曞悎'
+ && this.stageName != '璇环'
+ ) {
+ this.showToast("鐘舵��1:" + this.stageName + "銆佷笉鑳藉仛 鍙栨秷 浜嗭紒","error");
+
+ }
+ else if (this.sapSendOK == '1') {
+ this.showToast("宸茬粡涓婁紶SAP銆佷笉鑳藉仛 鍙栨秷 浜嗭紒","");
+ }
+ else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) {
+ this.showToast("璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒","error");
+ }
+ else if (this.jobCategory == '鏀彺') {
+ this.showToast("璇环鎵�鏈変汉鏄姪鐞嗙殑锛屽厛璇蜂慨鏀瑰埌閿�鍞媴褰擄紒","");
+ }
+ //XLIU-CG98L5 銆愬鎵樸�戙�愯瘎浼般�戞柊闇�姹�-鎷涙爣椤圭洰/璇环瀵瑰簲娴佹爣銆佸簾鏍囨敼鍠� start
+ //else if({!NOT(ISBLANK(Opportunity.Bidding_Project_Name_Bid__c))}&& '{!Opportunity.subInfoType__c}' != '3-1锛氬簾鏍囧叕鍛�' &&'{!Opportunity.subInfoType__c}' != '3-2锛氭祦鏍囧叕鍛�'){
+ else if(this.biddingProjectNameBid != undefined && sqlResult.size == 0){
+ this.showToast("鏈夋嫑鎶曟爣椤圭洰鏃跺彧鑳藉仛澶卞崟鎴栭儴鍒嗗け鍗曟姤鍛婏紒","error");
+ }
+ //XLIU-CG98L5 銆愬鎵樸�戙�愯瘎浼般�戞柊闇�姹�-鎷涙爣椤圭洰/璇环瀵瑰簲娴佹爣銆佸簾鏍囨敼鍠� end
+ else {
+ location.href = '/a1U/e?retURL=%2F'+ this.recordId +
+ '&RecordType=01210000000R4hH' +
+ '&CF00N10000004lbGT=' + this.name +
+ '&CF00N10000004lbGT_lkid=' + this.recordId +
+ '&CF00N10000006QShg=' + this.salesAssistantName +
+ '&CF00N10000006QShg_lkid=' + this.salesAssistantID +
+ '&CF00N10000006QShq='+ this.managerName +
+ '&CF00N10000006QShq_lkid=' + this.salesManagerDepartmentID +
+ '&CF00N10000006QShb=' + this.salesOwnerBuchang +
+ '&CF00N10000006QShb_lkid=' + this.salesOwnerBuchangID +
+ '';
+ }
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js-meta.xml b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js-meta.xml
new file mode 100644
index 0000000..329e839
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>54.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__RecordPage</target>
+ <target>lightning__AppPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLoseReport/__tests__/lexLoseReport.test.js b/force-app/main/default/lwc/lexLoseReport/__tests__/lexLoseReport.test.js
new file mode 100644
index 0000000..12c14ec
--- /dev/null
+++ b/force-app/main/default/lwc/lexLoseReport/__tests__/lexLoseReport.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexLoseReport from 'c/lexLoseReport';
+
+describe('c-lex-lose-report', () => {
+ afterEach(() => {
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
+ while (document.body.firstChild) {
+ document.body.removeChild(document.body.firstChild);
+ }
+ });
+
+ it('TODO: test case generated by CLI command, please fill in test logic', () => {
+ // Arrange
+ const element = createElement('c-lex-lose-report', {
+ is: LexLoseReport
+ });
+
+ // Act
+ document.body.appendChild(element);
+
+ // Assert
+ // const div = element.shadowRoot.querySelector('div');
+ expect(1).toBe(1);
+ });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLoseReport/lexLoseReport.css b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.css
new file mode 100644
index 0000000..93da52a
--- /dev/null
+++ b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.css
@@ -0,0 +1,10 @@
+.lexLoseReportHolder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+.container .uiContainerManager{
+ display: none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLoseReport/lexLoseReport.html b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.html
new file mode 100644
index 0000000..d7e25f9
--- /dev/null
+++ b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.html
@@ -0,0 +1,6 @@
+<template>
+ <div class="lexLoseReportHolder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLoseReport/lexLoseReport.js b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.js
new file mode 100644
index 0000000..7b167ea
--- /dev/null
+++ b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.js
@@ -0,0 +1,102 @@
+/*
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-14 10:16:19
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 10:41:46
+ */
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import init from '@salesforce/apex/OpportunityLightingButtonController.initForLostReportButton';
+export default class LexLoseReport extends LightningElement {
+ @api recordId;
+ stageName;
+ sapSendOK;
+ cntLostCancelReport;
+ name;
+ salesAssistantName;
+ salesAssistantID;
+ managerName;
+ salesManagerDepartmentID;
+ salesOwnerBuchang;
+ salesOwnerBuchangID;
+ IsLoading = true;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ console.log(111);
+ console.log(currentPageReference);
+
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ console.log("str");
+ console.log(str);
+ this.recordId = str;
+ }
+ }
+ }
+ connectedCallback(){
+ init({
+ recordId: this.recordId
+ }).then(result=>{
+ this.stageName = result.stageName;
+ this.sapSendOK = result.sapSendOK;
+ this.cntLostCancelReport = result.cntLostCancelReport;
+ this.name = result.name;
+ this.salesAssistantID = result.salesAssistantID;
+ this.salesAssistantName = result.salesAssistantName;
+ this.managerName = result.managerName;
+ this.salesManagerDepartmentID = result.salesManagerDepartmentID;
+ this.salesOwnerBuchang = result.salesOwnerBuchang;
+ this.salesOwnerBuchangID = result.salesOwnerBuchangID;
+ this.loseReport();
+ })
+ }
+ loseReport(){
+ // js銇牬鍚堛�佺炕瑷炽仌銈屻仧鍊ゃ亴銇с倠銇仹銆佽娉ㄦ剰
+ if (this.stageName != '寮曞悎'
+ && this.stageName != '璇环'
+ ) {
+ this.showToast("鐘舵��1:" + this.stageName + "銆佷笉鑳藉仛 澶卞崟 浜嗭紒","error");
+ }
+ else if (this.sapSendOK == '1') {
+ this.showToast("宸茬粡涓婁紶SAP銆佷笉鑳藉仛 澶卞崟 浜嗭紒","error");
+ }
+ else if (this.cntLostCancelReport > 0) {
+ this.showToast("璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒","error");
+ }
+ //else if({!Not(ISBLANK(Opportunity.Bidding_Project_Name_Bid__c))} && //'{!Opportunity.InfoTypeBid__c}' != '3锛氱粨鏋�' ){
+ //alert("鍏宠仈鎷涙姇鏍囬」鐩殑璇环锛屽彧鑳藉湪鏈夌粨鏋滃悗鍋氬け鍗曟姤鍛婏紒");
+ //}
+ else {
+ location.href = '/a1U/e?retURL=%2F' + this.recordId +
+ '&RecordType=01210000000R4hM' +
+ '&CF00N10000004lbGT=' + this.name +
+ '&CF00N10000004lbGT_lkid=' + this.recordId +
+ '&CF00N10000006QShg=' + this.salesAssistantName +
+ '&CF00N10000006QShg_lkid=' + this.salesAssistantID +
+ '&CF00N10000006QShq=' + this.managerName +
+ '&CF00N10000006QShq_lkid=' + this.salesManagerDepartmentID +
+ '&CF00N10000006QShb=' + this.salesOwnerBuchang +
+ '&CF00N10000006QShb_lkid=' + this.salesOwnerBuchangID +
+ '';
+ }
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ }
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLoseReport/lexLoseReport.js-meta.xml b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.js-meta.xml
new file mode 100644
index 0000000..3392981
--- /dev/null
+++ b/force-app/main/default/lwc/lexLoseReport/lexLoseReport.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>54.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__RecordPage</target>
+ <target>lightning__AppPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationProductNew/__tests__/lexQuotationProductNew.test.js b/force-app/main/default/lwc/lexQuotationProductNew/__tests__/lexQuotationProductNew.test.js
new file mode 100644
index 0000000..f8c78a9
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationProductNew/__tests__/lexQuotationProductNew.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexQuotationProductNew from 'c/lexQuotationProductNew';
+
+describe('c-lex-quotation-product-new', () => {
+ afterEach(() => {
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
+ while (document.body.firstChild) {
+ document.body.removeChild(document.body.firstChild);
+ }
+ });
+
+ it('TODO: test case generated by CLI command, please fill in test logic', () => {
+ // Arrange
+ const element = createElement('c-lex-quotation-product-new', {
+ is: LexQuotationProductNew
+ });
+
+ // Act
+ document.body.appendChild(element);
+
+ // Assert
+ // const div = element.shadowRoot.querySelector('div');
+ expect(1).toBe(1);
+ });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.html b/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.html
new file mode 100644
index 0000000..1ac43b5
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.html
@@ -0,0 +1,6 @@
+<template>
+ <div class="lexQuotationRequestHolder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js b/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js
new file mode 100644
index 0000000..6720168
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js
@@ -0,0 +1,67 @@
+/*
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-14 17:15:33
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 17:20:45
+ */
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import init from '@salesforce/apex/OpportunityLightingButtonController.initForQuotationProductNewButton';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+
+export default class LexQuotationProductNew extends LightningElement {
+ @api recordId;
+ currencyIsoCode;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ console.log(111);
+ console.log(currentPageReference);
+
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ console.log("str");
+ console.log(str);
+ this.recordId = str;
+ }
+ }
+ }
+ connectedCallback(){
+ init({
+ recordId:this.recordId
+ }).then(result=>{
+ this.currencyIsoCode = result.currencyIsoCode;
+ this.quotationProductNew();
+ }).catch(error=>{
+ console.log(error);
+ });
+ }
+ quotationProductNew(){
+ var Currency = this.currencyIsoCode;
+ var OppID = this.recordId;
+ if (Currency == 'CNY'){
+ var url = '/00O10000002jviu?pv0=' + OppID;
+ }
+ else if (Currency == 'USD'){
+ var url = '/00O10000005Ju6L?pv0=' + OppID;
+ }
+ window.open(url);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ }
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js-meta.xml b/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js-meta.xml
new file mode 100644
index 0000000..3392981
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationProductNew/lexQuotationProductNew.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>54.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__RecordPage</target>
+ <target>lightning__AppPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationRequest/__tests__/lexQuotationRequest.test.js b/force-app/main/default/lwc/lexQuotationRequest/__tests__/lexQuotationRequest.test.js
new file mode 100644
index 0000000..2e33a91
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationRequest/__tests__/lexQuotationRequest.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexQuotationRequest from 'c/lexQuotationRequest';
+
+describe('c-lex-quotation-request', () => {
+ afterEach(() => {
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
+ while (document.body.firstChild) {
+ document.body.removeChild(document.body.firstChild);
+ }
+ });
+
+ it('TODO: test case generated by CLI command, please fill in test logic', () => {
+ // Arrange
+ const element = createElement('c-lex-quotation-request', {
+ is: LexQuotationRequest
+ });
+
+ // Act
+ document.body.appendChild(element);
+
+ // Assert
+ // const div = element.shadowRoot.querySelector('div');
+ expect(1).toBe(1);
+ });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.css b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.css
new file mode 100644
index 0000000..e2d6ce2
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.css
@@ -0,0 +1,10 @@
+.lexQuotationRequestHolder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+.container .uiContainerManager{
+ display: none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.html b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.html
new file mode 100644
index 0000000..dff927d
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.html
@@ -0,0 +1,14 @@
+<!--
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-14 11:09:28
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 11:10:38
+-->
+<template>
+ <div class="lexQuotationRequestHolder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js
new file mode 100644
index 0000000..d968b59
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js
@@ -0,0 +1,73 @@
+/*
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-14 11:09:28
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 11:21:24
+ */
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import queryForQuotationRequestButton from '@salesforce/apex/OpportunityLightingButtonController.queryForQuotationRequestButton';
+import init from '@salesforce/apex/OpportunityLightingButtonController.initForQuotationRequestButton';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+
+export default class LexQuotationRequest extends LightningElement {
+ @api recordId;
+ biddingProjectNameBidId;
+ estimationId;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ console.log(111);
+ console.log(currentPageReference);
+
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ console.log("str");
+ console.log(str);
+ this.recordId = str;
+ }
+ }
+ }
+ connectedCallback(){
+ init({
+ recordId: this.recordId
+ }).then(result=>{
+ this.biddingProjectNameBidId = result.biddingProjectNameBidId;
+ this.estimationId = result.estimationId;
+ this.quotationRequest();
+ })
+ }
+ quotationRequest(){
+ queryForQuotationRequestButton({
+ recordId: this.recordId
+ }).then(result=>{
+ var records = result;
+ var size =records.length;
+ if(size > 1){
+ this.showToast("鏈�2涓垨鑰�2涓互涓婄殑鑽夋涓姤浠峰鎵橈紝璇风‘璁ゃ��","error");
+ }else if(size == 1){
+ var raes = records[0].Id;
+ location.href = "/apex/NewQuoteIrai?id="+ raes+"&tenderid=" + this.biddingProjectNameBidId;
+ }else{
+ location.href = "/apex/NewQuoteIrai?oppid=" + this.recordId + "&oppquoid=" + this.estimationId + "&tenderid=" + this.biddingProjectNameBidId;
+ }
+ this.dispatchEvent(new CloseActionScreenEvent());
+ })
+ }
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ }
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js-meta.xml b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js-meta.xml
new file mode 100644
index 0000000..3392981
--- /dev/null
+++ b/force-app/main/default/lwc/lexQuotationRequest/lexQuotationRequest.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>54.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__RecordPage</target>
+ <target>lightning__AppPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexStockApply/__tests__/lexStockApply.test.js b/force-app/main/default/lwc/lexStockApply/__tests__/lexStockApply.test.js
new file mode 100644
index 0000000..b8885a7
--- /dev/null
+++ b/force-app/main/default/lwc/lexStockApply/__tests__/lexStockApply.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexStockApply from 'c/lexStockApply';
+
+describe('c-lex-stock-apply', () => {
+ afterEach(() => {
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
+ while (document.body.firstChild) {
+ document.body.removeChild(document.body.firstChild);
+ }
+ });
+
+ it('TODO: test case generated by CLI command, please fill in test logic', () => {
+ // Arrange
+ const element = createElement('c-lex-stock-apply', {
+ is: LexStockApply
+ });
+
+ // Act
+ document.body.appendChild(element);
+
+ // Assert
+ // const div = element.shadowRoot.querySelector('div');
+ expect(1).toBe(1);
+ });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexStockApply/lexStockApply.css b/force-app/main/default/lwc/lexStockApply/lexStockApply.css
new file mode 100644
index 0000000..39dab40
--- /dev/null
+++ b/force-app/main/default/lwc/lexStockApply/lexStockApply.css
@@ -0,0 +1,10 @@
+.lexStockApplyHolder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+.container .uiContainerManager{
+ display: none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexStockApply/lexStockApply.html b/force-app/main/default/lwc/lexStockApply/lexStockApply.html
new file mode 100644
index 0000000..5674b24
--- /dev/null
+++ b/force-app/main/default/lwc/lexStockApply/lexStockApply.html
@@ -0,0 +1,6 @@
+<template>
+ <div class="lexStockApplyHolder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexStockApply/lexStockApply.js b/force-app/main/default/lwc/lexStockApply/lexStockApply.js
new file mode 100644
index 0000000..e82a54a
--- /dev/null
+++ b/force-app/main/default/lwc/lexStockApply/lexStockApply.js
@@ -0,0 +1,114 @@
+/*
+ * @Description:
+ * @version:
+ * @Author: chen jing wu
+ * @Date: 2023-04-14 13:04:53
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-04-14 17:54:56
+ */
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import updateForStockApplyButton from '@salesforce/apex/OpportunityLightingButtonController.updateForStockApplyButton';
+import init from '@salesforce/apex/OpportunityLightingButtonController.initForStockApplyButton';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { loadScript } from "lightning/platformResourceLoader";
+import connection from '@salesforce/resourceUrl/connection20';
+export default class LexStockApply extends LightningElement {
+ @api recordId;
+ stockApplyStatus;
+ lastOpportunityFileId;
+ IsLoading = true;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ console.log(111);
+ console.log(currentPageReference);
+
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ console.log("str");
+ console.log(str);
+ this.recordId = str;
+ }
+ }
+ }
+ connectedCallback(){
+ init({
+ recordId: this.recordId
+ }).then(result=>{
+ console.log(result);
+ this.stockApplyStatus = result.stockApplyStatus;
+ this.lastOpportunityFileId = result.lastOpportunityFileId;
+ this.stockApply();
+ })
+ }
+ stockApply(){
+ var status = this.stockApplyStatus;
+ if (status != '鑽夋涓�' && status != '濉啓瀹屾瘯' && status != '涓嶆壒鍑�' && status != '' && status != undefined) {
+ this.showToast("澶囪揣鐢宠鐘舵�佷笉姝g‘锛屼笉鑳芥彁浜ゅ璐х敵璇枫��","error");
+ return;
+ }
+ var oppfile = this.lastOpportunityFileId;
+ if (oppfile == undefined || oppfile == '') {
+ this.showToast("璇蜂笂浼犺浠锋枃浠躲��","error");
+ return;
+ }
+
+ if (!confirm("涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵")) {
+ this.dispatchEvent(new CloseActionScreenEvent);
+ return;
+ }
+
+ updateForStockApplyButton({
+ recordId: this.recordId,
+ flag: true
+ }).then(result=>{
+ if(result){
+ this.showToast(result,"error");
+ return;
+ }
+ Promise.all([
+ loadScript(this,connection)
+ ]).then(() =>{
+ var request = new window.sforce.ProcessSubmitRequest();
+ request.objectId = this.recordId;
+ console.log("s");
+ console.log(request);
+ console.log("e");
+ var processResults = window.sforce.Connection.prototype.process([request]);
+ console.log(processResults);
+ if (processResults[0].errors != null) {
+ updateForStockApplyButton({
+ recordId: this.recordId,
+ flag: false
+ }).then(result=>{
+ if(result){
+ this.showToast(result,"error");
+ return;
+ }
+ this.IsLoading = false;
+ this.updateRecordView(this.recordId);
+ this.dispatchEvent(new CloseActionScreenEvent);
+ })
+ }
+ });
+ }).catch(error=>{
+ console.log(error);
+ })
+ }
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent);
+ }
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexStockApply/lexStockApply.js-meta.xml b/force-app/main/default/lwc/lexStockApply/lexStockApply.js-meta.xml
new file mode 100644
index 0000000..3392981
--- /dev/null
+++ b/force-app/main/default/lwc/lexStockApply/lexStockApply.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>54.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__RecordPage</target>
+ <target>lightning__AppPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/staticresources/connection20.js b/force-app/main/default/staticresources/connection20.js
new file mode 100644
index 0000000..c0616f1
--- /dev/null
+++ b/force-app/main/default/staticresources/connection20.js
@@ -0,0 +1,1935 @@
+锘�/*
+Salesforce.com AJAX Connector 51.0
+Copyright, 1999, salesforce.com, inc.
+All Rights Reserved
+*/
+/** check if sforce is already created by some other lib*/
+window.sforce = window.sforce || {};
+
+sforce.internal = {};
+/** StringBuffer */
+
+sforce.StringBuffer = function() {
+ this.buffer = [];
+
+ this.append = function (s) {
+ this.buffer.push(s);
+ return this;
+ };
+
+ this.toString = function() {
+ return this.buffer.join("");
+ };
+};
+
+/** Base64Binary */
+sforce.Base64Binary = function(text) {
+ this.input = text;
+};
+
+sforce.Base64Binary.prototype.keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+
+sforce.Base64Binary.prototype.toString = function() {
+ var output = [];
+ var chr1, chr2, chr3 = "";
+ var enc1, enc2, enc3, enc4 = "";
+ var i = 0;
+ do {
+ chr1 = this.input.charCodeAt(i++);
+ chr2 = this.input.charCodeAt(i++);
+ chr3 = this.input.charCodeAt(i++);
+ enc1 = chr1 >> 2;
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+ enc4 = chr3 & 63;
+ if (isNaN(chr2)) {
+ enc3 = enc4 = 64;
+ } else if (isNaN(chr3)) {
+ enc4 = 64;
+ }
+ output.push(this.keyStr.charAt(enc1) + this.keyStr.charAt(enc2) + this.keyStr.charAt(enc3) + this.keyStr.charAt(enc4));
+ chr1 = chr2 = chr3 = "";
+ enc1 = enc2 = enc3 = enc4 = "";
+ } while (i < this.input.length);
+ return output.join("");
+};
+
+sforce.Base64Binary.prototype.decode = function(input) {
+ var output = [];
+ var chr1, chr2, chr3 = "";
+ var enc1, enc2, enc3, enc4 = "";
+ var i = 0;
+ var base64test = /[^A-Za-z0-9\+\/\=]/g;
+ if (base64test.exec(input)) {
+ alert("There were invalid base64 characters in the input text.\n" +
+ "Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" + "Expect errors in decoding.");
+ }
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
+ do {
+ enc1 = this.keyStr.indexOf(input.charAt(i++));
+ enc2 = this.keyStr.indexOf(input.charAt(i++));
+ enc3 = this.keyStr.indexOf(input.charAt(i++));
+ enc4 = this.keyStr.indexOf(input.charAt(i++));
+ chr1 = (enc1 << 2) | (enc2 >> 4);
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+ chr3 = ((enc3 & 3) << 6) | enc4;
+ output.push(String.fromCharCode(chr1));
+ if (enc3 != 64) {
+ output.push(String.fromCharCode(chr2));
+ }
+ if (enc4 != 64) {
+ output.push(String.fromCharCode(chr3));
+ }
+ chr1 = chr2 = chr3 = "";
+ enc1 = enc2 = enc3 = enc4 = "";
+ } while (i < input.length);
+ return output.join("");
+};
+
+/**DateCodec.js*/
+
+sforce.internal.dateToString = function(theDate) {
+ var today = theDate;
+ var year = today.getFullYear();
+ var month = today.getMonth() + 1;
+ var day = today.getDate();
+ return year + "-" + month + "-" + day;
+};
+
+sforce.internal.dateTimeToString = function(theDate) {
+ var today = theDate;
+ var year = today.getFullYear();
+ var month = today.getMonth() + 1;
+ var day = today.getDate();
+ var hour = today.getHours();
+ var minute = today.getMinutes();
+ var second = today.getSeconds();
+
+ var offset = today.getTimezoneOffset();
+ var pm = (offset < 0) ? "+" : "-";
+ offset = Math.abs(offset);
+ var hourdifference = offset / 60;
+ var minutedifference = offset % 60;
+
+ if (second <= 9) {
+ second = "0" + second;
+ }
+
+ var milli = today.getMilliseconds();
+ if (milli !== 0) {
+ milli = "." + milli;
+ if (milli.length > 4) {
+ milli = milli.substring(0, 4);
+ }
+ second = second + milli;
+ }
+
+ var timezone;
+
+ if (offset === 0) {
+ timezone = "Z";
+ } else {
+ if (minutedifference < 10) {
+ minutedifference = "0" + minutedifference;
+ }
+ if (hourdifference < 10) {
+ hourdifference = "0" + hourdifference;
+ }
+ timezone = pm + hourdifference + ":" + minutedifference;
+ }
+
+ if (month <= 9) {
+ month = "0" + month;
+ }
+ if (day <= 9) {
+ day = "0" + day;
+ }
+ if (hour <= 9) {
+ hour = "0" + hour;
+ }
+ if (minute <= 9) {
+ minute = "0" + minute;
+ }
+
+ return year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":" + second + timezone;
+};
+
+
+sforce.internal.stringToDate = function(source) {
+ var bc = false;
+ if (source === null || source.length === 0) {
+ throw "Unable to parse dateTime";
+ }
+
+ if (source.charAt(0) == '+') {
+ source = source.substring(1);
+ }
+
+ if (source.charAt(0) == '-') {
+ source = source.substring(1);
+ bc = true;
+ }
+
+ if (source.length != 10) {
+ throw ("Unable to parse date, " + source + " length != 10");
+ }
+
+ if (source.charAt(4) != '-' || source.charAt(7) != '-') {
+ throw ("Unable to parse date");
+ }
+
+ var year = source.substring(0, 4);
+ var month = source.substring(5, 7);
+ var day = source.substring(8, 10);
+
+ var date = new Date(year, month-1, day, 0, 0, 0);
+ date.setMilliseconds(0);
+ return date;
+};
+
+
+sforce.internal.stringToDateTime = function(source) {
+ var bc = false;
+ if (source === null || source.length === 0) {
+ throw "Unable to parse dateTime";
+ }
+
+ if (source.charAt(0) == '+') {
+ source = source.substring(1);
+ }
+ if (source.charAt(0) == '-') {
+ source = source.substring(1);
+ bc = true;
+ }
+
+ if (source.length < 19) {
+ throw ("Unable to parse dateTime");
+ }
+
+ if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
+ source.charAt(10) != 'T') {
+ throw ("Unable to parse dateTime");
+ }
+
+ if (source.charAt(13) != ':' || source.charAt(16) != ':') {
+ throw ("Unable to parse dateTime");
+ }
+
+ var year = source.substring(0, 4);
+ var month = source.substring(5, 7);
+ var day = source.substring(8, 10);
+ var hour = source.substring(11, 13);
+ var min = source.substring(14, 16);
+ var sec = source.substring(17, 19);
+
+ var date = new Date(year, month-1, day, hour, min, sec);
+
+ var pos = 19;
+
+ // parse optional milliseconds
+ if (pos < source.length && source.charAt(pos) == '.') {
+ var milliseconds = 0;
+ var start = ++pos;
+ while (pos < source.length && sforce.internal.isDigit(source.charAt(pos))) {
+ pos++;
+ }
+ var decimal = source.substring(start, pos);
+ if (decimal.length == 3) {
+ milliseconds = decimal;
+ } else if (decimal.length < 3) {
+ milliseconds = (decimal + "000").substring(0, 3);
+ } else {
+ milliseconds = decimal.substring(0, 3);
+ if (decimal.charAt(3) >= '5') {
+ ++milliseconds;
+ }
+ }
+
+ date.setMilliseconds(milliseconds);
+ }
+
+ var offset = date.getTimezoneOffset() * 60000;
+ //offset in milli;
+
+ // parse optional timezone
+ if (pos + 5 < source.length &&
+ (source.charAt(pos) == '+' || (source.charAt(pos) == '-'))) {
+ if (!sforce.internal.isDigit(source.charAt(pos + 1)) ||
+ !sforce.internal.isDigit(source.charAt(pos + 2)) ||
+ source.charAt(pos + 3) != ':' ||
+ !sforce.internal.isDigit(source.charAt(pos + 4)) ||
+ !sforce.internal.isDigit(source.charAt(pos + 5))) {
+ throw "Unable to parse dateTime";
+ }
+ var hours = (source.charAt(pos + 1) - '0') * 10 + source.charAt(pos + 2) - '0';
+ var mins = (source.charAt(pos + 4) - '0') * 10 + source.charAt(pos + 5) - '0';
+ var mseconds = (hours * 60 + mins) * 60 * 1000;
+
+ // subtract milliseconds from current date to obtain GMT
+ if (source.charAt(pos) == '+') {
+ mseconds = -mseconds;
+ }
+
+ date = new Date(date.getTime() - offset + mseconds);
+ pos += 6;
+ }
+
+ if (pos < source.length && source.charAt(pos) == 'Z') {
+ pos++;
+ date = new Date(date.getTime() - offset);
+ }
+
+ if (pos < source.length) {
+ throw ("Unable to parse dateTime");
+ }
+
+ return date;
+};
+
+
+sforce.internal.isDigit = function (ch) {
+ if (ch == '0' || ch == '1' || ch == '2' || ch == '3' || ch == '4' ||
+ ch == '5' || ch == '6' || ch == '7' || ch == '8' || ch == '9') {
+ return true;
+ } else {
+ return false;
+ }
+};
+/** Xml */
+
+sforce.Xml = function(name) {
+};
+
+sforce.Xml.prototype.toXml = function (sobjectNs, name, writer) {
+ writer.writeStartElement(name, sobjectNs);
+ if (this._xsiType) {
+ writer.writeXsiType(this._xsiType);
+ }
+ for (var f in this) {
+ if ("_name" == f || "_xsiType" == f) {
+ //skip
+ } else {
+ var val = this[f];
+ if (typeof val != "function") {
+ // if (typeof val == "array") {
+ if (Array.isArray(val)) {
+ for (var i=0; i<val.length; i++) {
+ this.writeValue(sobjectNs, writer, f, val[i]);
+ }
+ } else {
+ this.writeValue(sobjectNs, writer, f, val);
+ }
+ }
+ }
+ }
+ writer.writeEndElement(name, sobjectNs);
+};
+
+
+sforce.Xml.prototype.writeValue = function (sobjectNs, writer, name, val) {
+ if (val === null) {
+ writer.writeNameValueNode("fieldsToNull", name);
+ return;
+ }
+ if (typeof(val) === "undefined") {
+ //TODO: throw "value for field " + name + " is undefined"; Bug: 100000000000Ufg
+ return; //skip for now
+ }
+ if (val.toXml) {
+ val.toXml(sobjectNs, name, writer);
+ } else {
+ writer.writeNameValueNode(name, val);
+ }
+};
+
+sforce.Xml.prototype.get = function(name) {
+ return this[name] ? this[name] : null;
+};
+
+sforce.Xml.prototype.set = function(name, value) {
+ this[name] = value;
+};
+
+sforce.Xml.prototype.getArray = function(name) {
+ var obj = this[name];
+ if (obj) {
+ if (obj.join) {
+ return obj;
+ } else {
+ return [obj];
+ }
+ } else {
+ return [];
+ }
+};
+
+sforce.Xml.prototype.getBoolean = function(name) {
+ return ("true" == this[name]) ? true : false;
+};
+
+sforce.Xml.prototype.getDate = function(name) {
+ if (this[name]) {
+ if (this[name].getFullYear) {
+ return this[name];
+ } else {
+ return sforce.internal.stringToDate(this[name]);
+ }
+ } else {
+ return null;
+ }
+};
+
+sforce.Xml.prototype.getDateTime = function(name) {
+ if (this[name]) {
+ if (this[name].getFullYear) {
+ return this[name];
+ } else {
+ return sforce.internal.stringToDateTime(this[name]);
+ }
+ } else {
+ return null;
+ }
+};
+
+sforce.Xml.prototype.getInt = function(name) {
+ if (this[name]) {
+ if (typeof this[name] === "number") {
+ return this[name];
+ } else {
+ return parseInt(this[name], 10);
+ }
+ } else {
+ throw "Unable to parse int field: " + name;
+ }
+};
+
+sforce.Xml.prototype.getFloat = function(name) {
+ if (this[name]) {
+ if (typeof this[name] === "number") {
+ return this[name];
+ } else {
+ return parseFloat(this[name]);
+ }
+ } else {
+ throw "Unable to parse float field: " + name;
+ }
+};
+
+sforce.Xml.prototype.getBase64Binary = function(name) {
+ if (this[name]) {
+ return sforce.Base64Binary.prototype.decode(this[name]);
+ } else {
+ throw "Unable to parse base64Binary field: " + name;
+ }
+};
+
+sforce.Xml.prototype.toString = function() {
+ var sb = new sforce.StringBuffer();
+ sb.append("{");
+
+ for (var f in this) {
+ var field = this[f];
+
+ if (!field) {
+ sb.append(f).append(":").append("" + field);
+ } else if (typeof(field) == "object") {
+ sb.append(f).append(":").append(field.toString());
+ } else if (field.join) {
+ sb.append(f).append(":").append("[");
+ for (var i = 0; i < field.length; i++) {
+ sb.append(field[i]);
+ if (i < field.length - 1) {
+ sb.append(", ");
+ }
+ }
+ sb.append("]");
+ } else if (typeof(field) == "function") {
+ continue;
+ } else {
+ sb.append(f).append(":").append("'" + field + "'");
+ }
+ sb.append(", ");
+ }
+
+ sb.append("}");
+ return sb.toString();
+};
+
+
+/** Debug */
+
+
+sforce.internal.Debug = function() {
+ this.output = null;
+ this.trace = false;
+ this.apexTrace = false;
+ this.win = null;
+ this.traceQueue = [];
+ this.quiet = false;
+
+ this.open = function() {
+ this.println("", "print");
+ };
+
+ this.println = function(s, type) {
+ if (this.quiet) {
+ return;
+ }
+
+ if (typeof(println) === "function") {
+ println(s, type);
+ return;
+ }
+
+ if (this.win === null || !this.win.document) {
+ this.output = null;
+ this.win = window.open((typeof window.UserContext != "undefined") ? UserContext.getUrl('/soap/ajax/51.0/debugshell.html') : '/soap/ajax/51.0/debugshell.html', '',
+ 'width=800,height=400,toolbar=no,location=no,directories=no,alwaysRaised=yes,' +
+ 'status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes');
+ }
+
+ if (this.output === null) {
+ this.findOutput();
+ }
+
+ if (this.output !== null) {
+ if (sforce.debug.traceQueue.length > 0) {
+ this.traceCallback();
+ }
+ this.win.println(s, type);
+ } else {
+ sforce.debug.traceQueue.push({message: s, type: type});
+ setTimeout(sforce.debug.traceCallback, 1000);
+ }
+ };
+
+ this.traceCallback = function() {
+ sforce.debug.findOutput();
+
+ if (sforce.debug.output === null) {
+ setTimeout(sforce.debug.traceCallback, 1000);
+ return;
+ }
+
+ for (var i=0; i<sforce.debug.traceQueue.length; i++) {
+ var element = sforce.debug.traceQueue[i];
+ sforce.debug.win.println(element.message, element.type);
+ }
+ sforce.debug.traceQueue = [];
+ };
+
+ this.findOutput = function() {
+ if (this.output === null) {
+ this.output = this.win.document.getElementById("output");
+ }
+ return this.output;
+ };
+
+ this.logXml = function(str) {
+ str = str.replace(/</g, "<");
+ str = str.replace(/>/g, ">");
+ str = "<textarea cols=80 rows=5 wrap=hard>" + str + "</textarea>";
+ this.println(str, "printxml");
+ };
+
+ this.log = function(str) {
+ this.println(str, "print");
+ };
+
+ this.logApex = function(response) {
+ var start = response.indexOf("<debugLog>");
+ var end = response.indexOf("</debugLog>");
+ if (start === -1)
+ start = 0;
+ else
+ start = start + '<debugLog>'.length;
+ if (end === -1) end = response.length;
+ var msg = response.substring(start, end);
+
+ this.println(msg, "printxml");
+ };
+};
+
+sforce.debug = new sforce.internal.Debug();
+
+/** Transport */
+
+sforce.internal._connections = [];
+
+sforce.internal.ConnectionHolder = function(connection, callback) {
+ this.connection = connection;
+ this.callback = callback;
+ this.timedout = false;
+};
+
+sforce.Transport = function(url) {
+ this.url = url;
+ this.connection = null;
+
+ this.newConnection = function() {
+ try {
+ this.connection = new ActiveXObject('Msxml2.XMLHTTP');
+ } catch(e) {
+ try {
+ this.connection = new ActiveXObject('Microsoft.XMLHTTP');
+ } catch(e) {
+ this.connection = new XMLHttpRequest();
+ }
+ }
+
+ return this.connection;
+ };
+
+ this.send = function (envelope, callback, async, timeout) {
+ this.newConnection();
+ if (async) {
+ this.connection.onreadystatechange = this.httpConnectionCallback;
+ }
+ var holder = new sforce.internal.ConnectionHolder(this.connection, callback);
+ sforce.internal._connections.push(holder);
+ this.connection.open("POST", this.url, async);
+ this.connection.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
+ this.connection.setRequestHeader("SOAPAction", "\"\"");
+ this.connection.setRequestHeader("Accept", "text/xml");
+ this.connection.setRequestHeader("X-SFDC-User-Agent", "SFAJAX 1.0");
+ this.connection.send(envelope);
+ if (async && typeof(timeout) !== "undefined") {
+ this.setTimeoutOn(holder, timeout);
+ }
+ if (!async) {
+ this.httpConnectionCallback();
+ }
+ };
+
+ this.setTimeoutOn = function (holder, timeout) {
+ function abortConnection() {
+ if (holder.connection.readyState !== 4) {
+ holder.timedout = true;
+ holder.connection.abort();
+ }
+ }
+ setTimeout(abortConnection, timeout);
+ };
+
+ this.httpConnectionCallback = function () {
+
+ for (var i = 0; i < sforce.internal._connections.length; i++) {
+ var holder = sforce.internal._connections[i];
+ if (holder !== null) {
+ if (holder.timedout) {
+ sforce.internal._connections[i] = null;
+ sforce.internal._connections.slice(i,1);
+ holder.callback.httpCallback("Remote invocation timed out", false);
+ } else if (holder.connection.readyState == 4) {
+ sforce.internal._connections[i] = null;
+ sforce.internal._connections.slice(i,1);
+ var success = holder.connection.status == 200;
+ if (sforce.debug.trace) {
+ sforce.debug.log("Response : status - " + holder.connection.status);
+ sforce.debug.logXml(holder.connection.responseText);
+ }
+ if (sforce.debug.apexTrace) {
+ sforce.debug.logApex(holder.connection.responseText);
+ }
+ if (holder.connection.responseXML && holder.connection.responseXML.documentElement) {
+ holder.callback.httpCallback(holder.connection.responseXML.documentElement, success);
+ } else {
+ holder.callback.httpCallback("Remote invocation failed, due to: " + holder.connection.responseText +
+ " status code: ", holder.connection.status);
+ }
+ }
+ }
+ }
+ };
+};
+/** XmlWriter */
+
+
+sforce.XmlWriter = function() {
+ this.buffer = new sforce.StringBuffer();
+ this.namespaces = {};
+ this.prefixCount = 0;
+ this.writingStartElement = false;
+};
+
+sforce.XmlWriter.prototype.writeStartElement = function(name, namesp, prefix) {
+ if (this.writingStartElement) {
+ this.buffer.append(">");
+ }
+ this.buffer.append("<");
+ var newns = false;
+ if (namesp) {
+ if (!this.namespaces[namesp] && this.namespaces[namesp] !== "") {
+ newns = true;
+ }
+ if (!prefix) {
+ prefix = this.getPrefix(namesp);
+ }
+ if (prefix !== null && prefix !== "") {
+ this.buffer.append(prefix);
+ this.buffer.append(":");
+ }
+ }
+
+ this.buffer.append(name);
+ if (newns === true) {
+ this.writeNamespace(namesp, prefix);
+ }
+ this.writingStartElement = true;
+};
+
+sforce.XmlWriter.prototype.writeEndElement = function(name, namesp) {
+ if (this.writingStartElement) {
+ this.buffer.append("/>");
+ } else {
+ this.buffer.append("</");
+ if (namesp) {
+ var prefix = this.getPrefix(namesp);
+ if (prefix && prefix !== "") {
+ this.buffer.append(prefix);
+ this.buffer.append(":");
+ }
+ }
+ this.buffer.append(name);
+ this.buffer.append(">");
+ }
+ this.writingStartElement = false;
+};
+
+sforce.XmlWriter.prototype.writeNamespace = function(namesp, prefix) {
+ if (prefix && "" !== prefix) {
+ this.namespaces[namesp] = prefix;
+ this.buffer.append(" ");
+ this.buffer.append("xmlns:");
+ this.buffer.append(prefix);
+ } else {
+ this.namespaces[namesp] = "";
+ this.buffer.append(" ");
+ this.buffer.append("xmlns");
+ }
+ this.buffer.append("=\"");
+ this.buffer.append(namesp);
+ this.buffer.append("\"");
+};
+
+sforce.XmlWriter.prototype.writeText = function(text) {
+ if (this.writingStartElement) {
+ this.buffer.append(">");
+ this.writingStartElement = false;
+ } else {
+ throw "Can only write text after a start element";
+ }
+ if (typeof text == 'string') {
+ text = text.replace(/&/g, '\&');
+ text = text.replace(/</g, '<');
+ text = text.replace(/>/g, '>');
+ }
+
+ this.buffer.append(text);
+};
+
+sforce.XmlWriter.prototype.writeXsiType = function(xsiType) {
+ this.writeNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+ this.writeAttribute("xsi:type", xsiType);
+};
+
+sforce.XmlWriter.prototype.writeAttribute = function(name, value) {
+ this.buffer.append(" " + name + "=\"" + value + "\"");
+};
+
+sforce.XmlWriter.prototype.getPrefix = function(namesp) {
+ var prefix = this.namespaces[namesp];
+ //sforce.debug.log("--------");
+ //sforce.debug.log(namesp + ":" + (prefix === null ? "null":prefix) + ":");
+ if (!prefix && prefix !== "") {
+ prefix = "ns" + this.prefixCount;
+ this.prefixCount++;
+ this.namespaces[namesp] = prefix;
+ return prefix;
+ }
+ return prefix;
+};
+
+sforce.XmlWriter.prototype.toString = function() {
+ return this.buffer.toString();
+};
+
+/** soap writer*/
+sforce.XmlWriter.prototype.soapNS = "http://schemas.xmlsoap.org/soap/envelope/";
+
+sforce.XmlWriter.prototype.startEnvelope = function() {
+ this.writeStartElement("Envelope", this.soapNS, "se");
+};
+
+sforce.XmlWriter.prototype.endEnvelope = function() {
+ this.writeEndElement("Envelope", this.soapNS);
+};
+
+sforce.XmlWriter.prototype.startHeader = function() {
+ this.writeStartElement("Header", this.soapNS, "se");
+};
+
+sforce.XmlWriter.prototype.endHeader = function() {
+ this.writeEndElement("Header", this.soapNS);
+};
+
+sforce.XmlWriter.prototype.startBody = function() {
+ this.writeStartElement("Body", this.soapNS, "se");
+};
+
+sforce.XmlWriter.prototype.endBody = function() {
+ this.writeEndElement("Body", this.soapNS);
+};
+
+sforce.XmlWriter.prototype.writeNameValueNode = function(name, value) {
+ if (value === null) {
+ this.writeStartElement(name);
+ this.writeNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+ this.writeAttribute("xsi:nill", "true");
+ this.writeEndElement(name);
+ return;
+ }
+
+ if (value.toUTCString) {
+ value = sforce.internal.dateTimeToString(value);
+ }
+ if (typeof value == "boolean") {
+ // boolean 'false' values get joined in string buffer,
+ // so convert to strings:
+ value = value ? "true" : "false";
+ }
+
+ if (value && value.join) {
+ for (var i=0; i<value.length; i++) {
+ this.writeStartElement(name);
+ this.writeText(value[i]);
+ this.writeEndElement(name);
+ }
+ } else {
+ this.writeStartElement(name);
+ this.writeText(value);
+ this.writeEndElement(name);
+ }
+};
+
+/** XmlReader */
+
+sforce.XmlReader = function(root) {
+ this.envelope = root;
+};
+
+sforce.XmlReader.prototype.getEnvelope = function() {
+ if (this.isTag("Envelope", this.envelope)) {
+ return this.envelope;
+ }
+ throw "Unable to find soap envelope, but found " + this.envelope.nodeName;
+};
+
+sforce.XmlReader.prototype.getBody = function() {
+ return this.getChild("Body", this.envelope);
+};
+
+sforce.XmlReader.prototype.getHeader = function() {
+ return this.getChild("Header", this.envelope);
+};
+
+sforce.XmlReader.prototype.getChild = function(name, node) {
+ var children = node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].nodeType == 1 && this.isTag(name, children[i])) {
+ return children[i];
+ }
+ }
+ return null;
+};
+
+sforce.XmlReader.prototype.getFirstElement = function(node) {
+ var children = node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].nodeType == 1) {
+ return children[i];
+ }
+ }
+ return null;
+};
+
+sforce.XmlReader.prototype.isTag = function(name, node) {
+ var ns = node.nodeName.split(":");
+ if (ns.length == 2 && ns[1] == name) {
+ return true;
+ }
+ if (ns.length == 1 && ns[0] == name) {
+ return true;
+ }
+ return false;
+};
+
+sforce.XmlReader.prototype.isNameValueNode = function(node) {
+ var children = node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].nodeType != 3) {
+ return false;
+ }
+ }
+
+ return true;
+};
+
+sforce.XmlReader.prototype.getTextValue = function(node) {
+ if (node.nodeType == 3) {
+ return node.nodeValue;
+ }
+ //todo: fix the hardcoded xsi prefix
+ var xsiNil = node.getAttribute("xsi:nil");
+ if (xsiNil == "true") {
+ return null;
+ }
+ var sb = "";
+ var children = node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].nodeType == 3) {
+ sb += children[i].nodeValue;
+ } else {
+ throw "Not a simple name value node";
+ }
+ }
+ return sb;
+};
+
+//todo: optimize
+/*
+sforce.XmlReader.prototype.toXmlObject2 = function(node) {
+ var children = node.childNodes;
+ var obj = new sforce.Xml();
+ for (var i = 0; i < children.length; i++) {
+ var child = children[i];
+ if (child.nodeType != 1) continue;
+ var name = child.nodeName;
+ var index = name.indexOf(":");
+ name = (index == -1) ? name : name.substring(index + 1);
+ var value;
+ if (this.isNameValueNode(child)) {
+ value = this.getTextValue(child);
+ } else {
+ value = this.toXmlObject(child);
+ }
+ this.addToObject(obj, name, value);
+ }
+ return obj;
+}
+*/
+
+
+sforce.XmlReader.prototype.toXmlObject = function(n) {
+ //todo: fix the hardcoded xsi prefix
+ var xsiNil = n.getAttribute("xsi:nil");
+ if (xsiNil == "true") {
+ return null;
+ }
+
+ var top = new sforce.Xml();
+ var stack = [];
+ stack.push({node: n, obj: top});
+
+ while (stack.length > 0) {
+ var st = stack.shift();
+
+ for (var child = st.node.firstChild; child !== null; child = child.nextSibling) {
+ if (child.nodeType != 1) {
+ continue;
+ }
+ var name = child.nodeName;
+ var index = name.indexOf(":");
+ name = (index == -1) ? name : name.substring(index + 1);
+ var value;
+
+ var isNameValue = true;
+ var sb = "";
+ for (var tc = child.firstChild; tc !== null; tc = tc.nextSibling) {
+ if (tc.nodeType != 3) {
+ isNameValue = false;
+ break;
+ } else {
+ sb += tc.nodeValue;
+ }
+ }
+
+ if (isNameValue) {
+ if (child.getAttribute("xsi:nil") == "true") {
+ value = null;
+ } else {
+ value = sb;
+ }
+ } else {
+ value = new sforce.Xml();
+ stack.push({node: child, obj: value});
+ }
+ if (!st.obj[name]) {
+ st.obj[name] = value;
+ } else {
+ if (st.obj[name].push) {
+ st.obj[name].push(value);
+ } else {
+ var old = st.obj[name];
+ if (name === "Id" && old === value) {
+ //skip, special case for dup Id in sobject
+ } else {
+ st.obj[name] = [];
+ st.obj[name].push(old);
+ st.obj[name].push(value);
+ }
+ }
+ }
+ }
+ }
+ return top;
+};
+
+
+/** SoapTransport */
+
+sforce.SoapTransport = function() {
+ this.connectionCallback = null;
+ this.result = null;
+ this.fault = null;
+ this.isAsync = true;
+ this.isArray = false;
+};
+
+sforce.SoapTransport.prototype.onFailure = function(res, writer) {
+ var error = "ERROR: ........... ";
+ alert(error + res);
+ this.result = null;
+};
+
+sforce.SoapTransport.prototype.send = function(url, writer, isArray, connectionCallback) {
+ this.isArray = isArray;
+ var transport = new sforce.Transport(url);
+ this.isAsync = connectionCallback ? true : false;
+ if (this.isAsync) {
+ this.connectionCallback = connectionCallback;
+ transport.send(writer.toString(), this, this.isAsync, connectionCallback.timeout);
+ } else {
+ transport.send(writer.toString(), this, this.isAsync);
+ if (this.fault !== null) {
+ throw this.fault;
+ }
+ return this.result;
+ }
+};
+
+sforce.SoapTransport.prototype.httpCallback = function(response, success) {
+ try {
+ if (success === true) {
+ var reader = new sforce.XmlReader(response);
+ var envelope = reader.getEnvelope();
+ var body = reader.getBody();
+ var operation = reader.getFirstElement(body);
+ if (operation === null) {
+ throw "Unable to find operation response element";
+ }
+ var resultArray = [];
+ var children = operation.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].nodeType != 1) {
+ continue;
+ }
+ if (reader.isNameValueNode(children[i])) {
+ resultArray.push(reader.getTextValue(children[i]));
+ } else {
+ resultArray.push(reader.toXmlObject(children[i]));
+ }
+ }
+
+ if (this.isArray) {
+ this.result = resultArray;
+ } else {
+ if (resultArray.length > 1) {
+ throw "Found more than one response: " + resultArray;
+ }
+ this.result = resultArray[0];
+ }
+
+ if (this.isAsync) {
+ try {
+ this.beforeCallback();
+ if (typeof this.connectionCallback == "function") {
+ this.connectionCallback(this.result);
+ } else {
+ if (this.connectionCallback.onSuccess) {
+ this.connectionCallback.onSuccess(this.result, this.connectionCallback.source);
+ } else {
+ throw "Unable to find onSuccess method in the callback object";
+ }
+ }
+ } finally {
+ this.afterCallback();
+ }
+ }
+ } else {
+ if (typeof(response.nodeName) !== "undefined") {
+ var reader2 = new sforce.XmlReader(response);
+ var envelope2 = reader2.getEnvelope();
+ var body2 = reader2.getBody();
+ var soapfaultEl = reader2.getFirstElement(body2);
+ var soapfault = reader2.toXmlObject(soapfaultEl);
+ this.sendFault(soapfault);
+ } else {
+ this.sendFault(response);
+ }
+ }
+ } catch(fault) {
+ this.sendFault(fault);
+ }
+};
+
+
+sforce.SoapTransport.prototype.sendFault = function(fault) {
+ if (this.isAsync) {
+ if (this.connectionCallback.onFailure) {
+ try {
+ this.beforeCallback();
+ this.connectionCallback.onFailure(fault, this.connectionCallback.source);
+ } finally {
+ this.afterCallback();
+ }
+ } else {
+ this.onFailure(fault);
+ }
+ } else {
+ this.fault = fault;
+ }
+};
+
+sforce.SoapTransport.prototype.beforeCallback = function () {};
+
+sforce.SoapTransport.prototype.afterCallback = function () {};
+
+/** SObject */
+
+
+sforce.SObject = function(type) {
+ this.type = type;
+};
+
+sforce.SObject.prototype = new sforce.Xml("sObjects");
+
+
+/** LeadConvert */
+
+
+sforce.LeadConvert = function() {
+};
+
+sforce.LeadConvert.prototype = new sforce.Xml("leadConverts");
+
+/** MergeRequest */
+
+
+sforce.MergeRequest = function() {
+};
+
+sforce.MergeRequest.prototype = new sforce.Xml("request");
+
+/** DescribeSoqlListViewsRequest - see describeSoqlListViews() */
+sforce.DescribeSoqlListViewsRequest = function() {
+};
+sforce.DescribeSoqlListViewsRequest.prototype = new sforce.Xml("request");
+
+/** DescribeSoqlListViewParams - see describeSoqlListViews() */
+sforce.DescribeSoqlListViewParams = function() {
+};
+sforce.DescribeSoqlListViewParams.prototype = new sforce.Xml("listViewParams");
+
+/** DescribePicklistsParam - see describePicklists() */
+sforce.DescribePicklistsParam = function() {
+};
+sforce.DescribePicklistsParam.prototype = new sforce.Xml("picklistParams");
+
+
+/** QuickAction */
+
+
+sforce.QuickAction = function() {
+};
+
+sforce.QuickAction.prototype = new sforce.Xml("quickActions");
+
+/** Connection */
+
+sforce.Connection = function() {
+ this.sessionId = null;
+ this.updateMru = null;
+ this.allowFieldTruncation = null;
+ this.disableFeedTracking = null;
+ this.streamingEnabled = null;
+ this.allOrNone = null;
+ this.client = null;
+ this.defaultNamespace = null;
+ this.batchSize = null;
+ this.loginScopeHeader = null;
+ this.emailHeader = null;
+ this.assignmentRuleHeader = null;
+ this.duplicateRuleHeader = null;
+ this.transferToUserId = null;
+ this.debuggingHeader = null;
+ this.serverUrl = (typeof window.UserContext != "undefined") ? UserContext.getUrl("/services/Soap/u/51.0") : "/services/Soap/u/51.0";
+};
+
+
+/** internal methods */
+
+sforce.internal.Parameter = function (n, v, a) {
+ this.name = n;
+ this.value = v;
+ this.isArray = a;
+};
+
+sforce.Connection.prototype.sforceNs = "urn:partner.soap.sforce.com";
+sforce.Connection.prototype.sobjectNs = "sobject.partner.soap.sforce.com";
+
+sforce.Connection.prototype.writeOne = function (writer, name, value, sobjectNs) {
+ if (value === null) {
+ writer.writeNameValueNode(name, null);
+ } else if (value.toXml) {
+ value.toXml(sobjectNs, name, writer);
+ } else {
+ writer.writeNameValueNode(name, value);
+ }
+};
+
+sforce.Connection.prototype.init = function(sessionId, serverUrl) {
+ this.sessionId = sessionId;
+ this.serverUrl = serverUrl;
+};
+
+sforce.Connection.prototype.login = function (username, password) {
+ var arg1 = new sforce.internal.Parameter("username", username, false);
+ var arg2 = new sforce.internal.Parameter("password", password, false);
+ var result = this.invoke("login", [arg1, arg2], false, null);
+ this.sessionId = result.sessionId;
+ return result;
+};
+
+sforce.Connection.prototype.describeSObject = function(type, callback) {
+ var arg = new sforce.internal.Parameter("sObjectType", type, false);
+ return this.invoke("describeSObject", [arg], false, callback);
+};
+
+sforce.Connection.prototype.describeSObjects = function(types, callback) {
+ var arg = new sforce.internal.Parameter("sObjectType", types, true);
+ return this.invoke("describeSObjects", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeSearchLayouts = function(type, callback) {
+ var arg = new sforce.internal.Parameter("sObjectType", type, true);
+ return this.invoke("describeSearchLayouts", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeListViews = function(type, callback) {
+ var arg = new sforce.internal.Parameter("sObjectType", type, true);
+ return this.invoke("describeListViews", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeSoqlListViews = function(name, type, callback) {
+ // this interface is only for a single list
+ // build up a request for the user - easier than making caller do it
+ var rp = new sforce.DescribeSoqlListViewParams();
+ rp.developerNameOrId = name;
+ rp.sobjectType = type;
+ var describeRequest = new sforce.DescribeSoqlListViewsRequest();
+ describeRequest.listViewParams = [ rp ];
+
+ var arg1 = new sforce.internal.Parameter("request", describeRequest, false);
+ return this.invoke("describeSoqlListViews", [arg1], false, callback);
+};
+
+sforce.Connection.prototype.describeGlobal = function(callback) {
+ return this.invoke("describeGlobal", [], false, callback);
+};
+
+sforce.Connection.prototype.describeLayout = function(type, layoutName, recordTypes, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjectType", type, false);
+ if (!layoutName) {
+ layoutName = null;
+ }
+ var arg2 = new sforce.internal.Parameter("layoutName", layoutName, false);
+ if (!recordTypes) {
+ recordTypes = [];
+ }
+ var arg3 = new sforce.internal.Parameter("recordTypeIds", recordTypes, true);
+ return this.invoke("describeLayout", [arg1, arg2, arg3], false, callback);
+};
+
+sforce.Connection.prototype.describeAvailableQuickActions = function(parentType, callback) {
+ var arg = new sforce.internal.Parameter("parentType", parentType, false);
+ return this.invoke("describeAvailableQuickActions", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeQuickActions = function(quickActionNames, callback) {
+ var arg = new sforce.internal.Parameter("quickActionNames", quickActionNames, true);
+ return this.invoke("describeQuickActions", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeQuickActionsForRecordType = function(quickActionNames, recordTypeId, callback) {
+ var arg = new sforce.internal.Parameter("quickActionNames", quickActionNames, true);
+ var arg2 = new sforce.internal.Parameter("recordTypeId", recordTypeId, false);
+ return this.invoke("describeQuickActionsForRecordType", [arg,arg2], true, callback);
+};
+
+sforce.Connection.prototype.performQuickActions = function(quickActions, callback) {
+ var arg = new sforce.internal.Parameter("quickActions", quickActions, true);
+ return this.invoke("performQuickActions", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeCompactLayouts = function(type, recordTypes, callback) {
+ var arg = new sforce.internal.Parameter("sObjectType", type, false);
+ if (!recordTypes) {
+ recordTypes = [];
+ }
+ var arg2 = new sforce.internal.Parameter("recordTypeIds", recordTypes, true);
+ return this.invoke("describeCompactLayouts", [arg, arg2], false, callback);
+};
+
+sforce.Connection.prototype.describePathAssistants = function(type, picklistValue, recordTypes, callback) {
+ var arg = new sforce.internal.Parameter("sObjectType", type, false);
+ if (!picklistValue) {
+ picklistValue = null;
+ }
+ var arg2 = new sforce.internal.Parameter("picklistValue", picklistValue, false);
+ if (!recordTypes) {
+ recordTypes = [];
+ }
+ var arg3 = new sforce.internal.Parameter("recordTypeIds", recordTypes, true);
+ return this.invoke("describePathAssistants", [arg, arg2, arg3], false, callback);
+};
+
+sforce.Connection.prototype.describePicklists = function(entityName, fieldNames, recordTypeId, callback) {
+ var picklistParams = new sforce.DescribePicklistsParam();
+ picklistParams.entityName = entityName;
+ picklistParams.fieldNames = fieldNames;
+ picklistParams.recordTypeId = recordTypeId;
+
+ var arg1 = new sforce.internal.Parameter("param", picklistParams, false);
+ return this.invoke("describePicklists", [arg1], false, callback);
+};
+
+sforce.Connection.prototype.describePrimaryCompactLayouts = function(sObjectTypes, callback) {
+ var arg = new sforce.internal.Parameter("sObjectTypes", sObjectTypes, true);
+ return this.invoke("describePrimaryCompactLayouts", [arg], true, callback);
+};
+
+sforce.Connection.prototype.describeApprovalLayout = function(type, approvalProcessNames, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjectType", type, false);
+ if (!approvalProcessNames) {
+ approvalProcessNames = [];
+ }
+ var arg2 = new sforce.internal.Parameter("approvalProcessNames", approvalProcessNames, true);
+ return this.invoke("describeApprovalLayout", [arg1, arg2], false, callback);
+};
+
+sforce.Connection.prototype.describeSObjectListViews = function(type, recentlyViewed, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjectType", type, false);
+ var arg2 = new sforce.internal.Parameter("recentlyViewed", recentlyViewed, false);
+ var arg3 = new sforce.internal.Parameter("isSoqlCompatible", isSoqlCompatible, false);
+ var arg4 = new sforce.internal.Parameter("limit", limit, false);
+ var arg5 = new sforce.internal.Parameter("offset", offset, false);
+ return this.invoke("describeSObjectListViews", [arg1, arg2, arg3, arg4, arg5], true, callback);
+};
+
+sforce.Connection.prototype.describeTabs = function(callback) {
+ return this.invoke("describeTabs", [], true, callback);
+};
+
+sforce.Connection.prototype.describeAllTabs = function(callback) {
+ return this.invoke("describeAllTabs", [], true, callback);
+};
+
+sforce.Connection.prototype.describeAppMenu = function(appMenuType, networkId, callback) {
+ var arg1 = new sforce.internal.Parameter("appMenuType", appMenuType, false);
+ var arg2 = new sforce.internal.Parameter("networkId", networkId, false);
+ return this.invoke("describeAppMenu", [arg1, arg2], true, callback);
+};
+
+sforce.Connection.prototype.describeFlexiPages = function(flexipageDevName, callback) {
+ var arg1 = new sforce.internal.Parameter("FlexiPage", flexipageDevName, false);
+ return this.invoke("describeFlexiPages", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.describeTheme = function(callback) {
+ return this.invoke("describeTheme", [], true, callback);
+};
+
+sforce.Connection.prototype.describeGlobalTheme = function(callback) {
+ return this.invoke("describeGlobalTheme", [], true, callback);
+};
+
+sforce.Connection.prototype.describeSoftphoneLayout = function(callback) {
+ return this.invoke("describeSoftphoneLayout", [], false, callback);
+};
+
+sforce.Connection.prototype.describeMiniLayout = function (type, recordTypeIds, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjectType", type, false);
+ var arg2 = new sforce.internal.Parameter("recordTypeIds", recordTypeIds, true);
+ return this.invoke("describeMiniLayout", [arg1, arg2], false, callback);
+};
+
+sforce.Connection.prototype.describeSearchScopeOrder = function(callback) {
+ return this.invoke("describeSearchScopeOrder", [], true, callback);
+};
+
+sforce.Connection.prototype.create = function (sobjects, callback) {
+ var arg = new sforce.internal.Parameter("sObjects", sobjects, true);
+ return this.invoke("create", [arg], true, callback);
+};
+
+sforce.Connection.prototype.update = function (sobjects, callback) {
+ var arg = new sforce.internal.Parameter("sObjects", sobjects, true);
+ return this.invoke("update", [arg], true, callback);
+};
+
+sforce.Connection.prototype.upsert = function (externalIDFieldName, sobjects, callback) {
+ var arg1 = new sforce.internal.Parameter("externalIDFieldName", externalIDFieldName, false);
+ var arg2 = new sforce.internal.Parameter("sObjects", sobjects, true);
+ return this.invoke("upsert", [arg1, arg2], true, callback);
+};
+
+sforce.Connection.prototype.deleteIds = function (ids, callback) {
+ var arg = new sforce.internal.Parameter("ids", ids, true);
+ return this.invoke("delete", [arg], true, callback);
+};
+
+sforce.Connection.prototype.deleteByExample = function (sobjects, callback) {
+ var arg = new sforce.internal.Parameter("sObjects", sobjects, true);
+ return this.invoke("deleteByExample", [arg], true, callback);
+};
+
+sforce.Connection.prototype.impersonateUser = function (ids, callback) {
+ var arg = new sforce.internal.Parameter("ids", ids, true);
+ return this.invoke("impersonateUser", [arg], true, callback);
+};
+sforce.Connection.prototype.query = function(queryString, callback) {
+ var arg = new sforce.internal.Parameter("queryString", queryString, false);
+ return this.invoke("query", [arg], false, callback);
+};
+
+sforce.Connection.prototype.queryAll = function(queryString, callback) {
+ var arg = new sforce.internal.Parameter("queryString", queryString, false);
+ return this.invoke("queryAll", [arg], false, callback);
+};
+
+sforce.Connection.prototype.queryMore = function(queryLocator, callback) {
+ var arg = new sforce.internal.Parameter("queryLocator", queryLocator, false);
+ return this.invoke("queryMore", [arg], false, callback);
+};
+
+sforce.Connection.prototype.retrieve = function(fieldList, sObjectType, ids, callback) {
+ var arg1 = new sforce.internal.Parameter("fieldList", fieldList, false);
+ var arg2 = new sforce.internal.Parameter("sObjectType", sObjectType, false);
+ var arg3 = new sforce.internal.Parameter("ids", ids, true);
+ return this.invoke("retrieve", [arg1, arg2, arg3], true, callback);
+};
+
+sforce.Connection.prototype.getAccessInfo = function(callback) {
+ return this.invoke("getAccessInfo", [], false, callback);
+};
+
+sforce.Connection.prototype.getUserInfo = function(callback) {
+ return this.invoke("getUserInfo", [], false, callback);
+};
+
+sforce.Connection.prototype.resetPassword = function(userId, callback) {
+ var arg1 = new sforce.internal.Parameter("userId", userId, false);
+ return this.invoke("resetPassword", [arg1], false, callback);
+};
+
+sforce.Connection.prototype.setPassword = function(userId, password, callback) {
+ var arg1 = new sforce.internal.Parameter("userId", userId, false);
+ var arg2 = new sforce.internal.Parameter("password", password, false);
+ return this.invoke("setPassword", [arg1, arg2], false, callback);
+};
+
+sforce.Connection.prototype.search = function(searchString, callback) {
+ var arg1 = new sforce.internal.Parameter("searchString", searchString, false);
+ return this.invoke("search", [arg1], false, callback);
+};
+
+sforce.Connection.prototype.getDeleted = function(sObjectType, startDate, endDate, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjectType", sObjectType, false);
+ var arg2 = new sforce.internal.Parameter("startDate", startDate, false);
+ var arg3 = new sforce.internal.Parameter("endDate", endDate, false);
+ return this.invoke("getDeleted", [arg1, arg2, arg3], false, callback);
+};
+
+sforce.Connection.prototype.getUpdated = function(sObjectType, startDate, endDate, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjectType", sObjectType, false);
+ var arg2 = new sforce.internal.Parameter("startDate", startDate, false);
+ var arg3 = new sforce.internal.Parameter("endDate", endDate, false);
+ return this.invoke("getUpdated", [arg1, arg2, arg3], false, callback);
+};
+
+
+sforce.Connection.prototype.getServerTimestamp = function(callback) {
+ return this.invoke("getServerTimestamp", [], false, callback);
+};
+
+sforce.Connection.prototype.convertLead = function(leadConverts, callback) {
+ var arg1 = new sforce.internal.Parameter("leadConverts", leadConverts, true);
+ return this.invoke("convertLead", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.merge = function(mergeRequest, callback) {
+ var arg1 = new sforce.internal.Parameter("request", mergeRequest, true);
+ return this.invoke("merge", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.findDuplicates = function(sObjects, callback) {
+ var arg1 = new sforce.internal.Parameter("sObjects", sObjects, true);
+ return this.invoke("findDuplicates", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.findDuplicatesByIds = function(ids, callback) {
+ var arg1 = new sforce.internal.Parameter("ids", ids, true);
+ return this.invoke("findDuplicatesByIds", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.undelete = function(ids, callback) {
+ var arg1 = new sforce.internal.Parameter("ids", ids, true);
+ return this.invoke("undelete", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.process = function(actions, callback) {
+ var arg1 = new sforce.internal.Parameter("actions", actions, true);
+ return this.invoke("process", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.sendEmail = function(messages, callback) {
+ var arg1 = new sforce.internal.Parameter("messages", messages, true);
+ return this.invoke("sendEmail", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.emptyRecycleBin = function(ids, callback) {
+ var arg1 = new sforce.internal.Parameter("ids", ids, true);
+ return this.invoke("emptyRecycleBin", [arg1], true, callback);
+};
+
+sforce.Connection.prototype.invalidateSessions = function(sessionIds, callback) {
+ var arg = new sforce.internal.Parameter("sessionIds", sessionIds, true);
+ return this.invoke("invalidateSessions", [arg], true, callback);
+};
+
+sforce.Connection.prototype.logout = function(callback) {
+ return this.invoke("logout", [], true, callback);
+};
+
+sforce.Connection.prototype.remoteFunction = function(args) {
+ if (!args.url) {
+ throw "url not defined";
+ }
+ if (!args.onSuccess) {
+ throw "onSuccess method not defined";
+ }
+
+ if (!args.method) {
+ args.method = "GET";
+ }
+ if (!args.mimeType) {
+ args.mimeType = "text/plain";
+ }
+
+ if (typeof(args.async) == 'undefined') {
+ args.async = true;
+ }
+
+ if (typeof(args.cache) == 'undefined') {
+ args.cache = false;
+ }
+
+ if (!(args.mimeType == "text/plain" ||
+ args.mimeType == "text/xml")) {
+ throw "Unknown mime type " + args.mimeType;
+ }
+
+ if (sforce.debug.trace) {
+ sforce.debug.log("Open connection to ... " + args.url);
+ }
+
+ var request = new sforce.Transport().newConnection();
+ var proxyUrl = (typeof window.UserContext != "undefined") ? UserContext.getUrl("/services/proxy") : "/services/proxy";
+ if (args.cache) {
+ proxyUrl = proxyUrl + "?end-point-url=" + args.url;
+ } else {
+ proxyUrl = proxyUrl + "?no-cache=" + new Date().getTime();
+ }
+ request.open(args.method, proxyUrl, args.async);
+
+ if (args.requestHeaders) {
+ for (var k in args.requestHeaders) {
+ if (typeof args.requestHeaders[k] != "function") {
+ request.setRequestHeader(k, args.requestHeaders[k]);
+ }
+ }
+ }
+
+ request.setRequestHeader("SalesforceProxy-Endpoint", args.url);
+ request.setRequestHeader("SalesforceProxy-SID", this.sessionId);
+
+ if (args.async) {
+ request.onreadystatechange = _remoteFunctionCallback;
+ }
+
+ if (sforce.debug.trace) {
+ sforce.debug.log("Sending ...");
+ }
+
+ if (args.requestData) {
+ request.send(args.requestData);
+ } else {
+ request.send(null);
+ }
+
+ if (sforce.debug.trace) {
+ sforce.debug.log("Done Sending ...");
+ }
+
+ if (!args.async) {
+ _remoteFunctionCallback();
+ }
+
+ function _remoteFunctionCallback() {
+ if (sforce.debug.trace) {
+ sforce.debug.log("callback called ...");
+ }
+ if (request.readyState == 4) {
+ if (request.status == 200) {
+ if (args.mimeType == "text/plain") {
+ args.onSuccess(request.responseText, request);
+ } else if (args.mimeType == "text/xml") {
+ if (!request.responseXML || !request.responseXML.documentElement) {
+ throw "Response not text/xml mime type: " + request.responseText;
+ }
+ args.onSuccess(request.responseXML.documentElement, request);
+ } else {
+ throw "unsupported mime type: " + args.mimeType;
+ }
+ } else {
+ if (args.onFailure) {
+ args.onFailure(request.responseText, request);
+ } else {
+ sforce.debug.log(request.responseText);
+ }
+ }
+ }
+ }
+};
+
+
+sforce.Connection.prototype.writeHeader = function(writer, headerNs) {
+ writer.startHeader();
+
+ writer.writeNamespace(headerNs, "sfns");
+
+ if (this.sessionId !== null) {
+ writer.writeStartElement("SessionHeader", headerNs);
+ writer.writeNameValueNode("sessionId", this.sessionId);
+ writer.writeEndElement("SessionHeader", headerNs);
+ }
+ if (typeof(this.organizationId) !== "undefined") {
+ throw "Use sforce.connection.loginScopeHeader.organizationId instead of sforce.connection.organizationId";
+ }
+ if (this.loginScopeHeader !== null) {
+ writer.writeStartElement("LoginScopeHeader", headerNs);
+ if (this.loginScopeHeader.organizationId !== null) {
+ writer.writeNameValueNode("organizationId", this.loginScopeHeader.organizationId);
+ }
+ if (this.loginScopeHeader.portalId !== null) {
+ writer.writeNameValueNode("portalId", this.loginScopeHeader.portalId);
+ }
+ writer.writeEndElement("LoginScopeHeader", headerNs);
+ }
+ if (this.client !== null || this.defaultNamespace !== null) {
+ writer.writeStartElement("CallOptions", headerNs);
+ if (this.client !== null) {
+ writer.writeNameValueNode("client", this.client);
+ }
+ if (this.defaultNamespace !== null) {
+ writer.writeNameValueNode("defaultNamespace", this.defaultNamespace);
+ }
+ writer.writeEndElement("CallOptions", headerNs);
+ }
+ if (this.batchSize !== null) {
+ writer.writeStartElement("QueryOptions", headerNs);
+ writer.writeNameValueNode("batchSize", this.batchSize);
+ writer.writeEndElement("QueryOptions", headerNs);
+ }
+ if (this.allowFieldTruncation !== null) {
+ writer.writeStartElement("AllowFieldTruncationHeader", headerNs);
+ writer.writeNameValueNode("allowFieldTruncation", this.allowFieldTruncation);
+ writer.writeEndElement("AllowFieldTruncationHeader", headerNs);
+ }
+ if (this.disableFeedTracking !== null) {
+ writer.writeStartElement("DisableFeedTrackingHeader", headerNs);
+ writer.writeNameValueNode("disableFeedTracking", this.disableFeedTracking);
+ writer.writeEndElement("DisableFeedTrackingHeader", headerNs);
+ }
+ if (this.streamingEnabled !== null) {
+ writer.writeStartElement("StreamingEnabledHeader", headerNs);
+ writer.writeNameValueNode("StreamingEnabled", this.streamingEnabled);
+ writer.writeEndElement("StreamingEnabledHeader", headerNs);
+ }
+ if (this.allOrNone !== null) {
+ writer.writeStartElement("AllOrNoneHeader", headerNs);
+ writer.writeNameValueNode("allOrNone", this.allOrNone);
+ writer.writeEndElement("AllOrNoneHeader", headerNs);
+ }
+ if (this.updateMru !== null) {
+ writer.writeStartElement("MruHeader", headerNs);
+ writer.writeNameValueNode("updateMru", this.updateMru);
+ writer.writeEndElement("MruHeader", headerNs);
+ }
+ if (this.emailHeader !== null) {
+ writer.writeStartElement("EmailHeader", headerNs);
+ if (this.emailHeader.triggerAutoResponseEmail) {
+ writer.writeNameValueNode("triggerAutoResponseEmail", this.emailHeader.triggerAutoResponseEmail);
+ }
+ if (this.emailHeader.triggerOtherEmail) {
+ writer.writeNameValueNode("triggerOtherEmail", this.emailHeader.triggerOtherEmail);
+ }
+ if (this.emailHeader.triggerUserEmail) {
+ writer.writeNameValueNode("triggerUserEmail", this.emailHeader.triggerUserEmail);
+ }
+ writer.writeEndElement("EmailHeader", headerNs);
+ }
+ if (this.assignmentRuleHeader !== null) {
+ writer.writeStartElement("AssignmentRuleHeader", headerNs);
+ if (this.assignmentRuleHeader.assignmentRuleId) {
+ writer.writeNameValueNode("assignmentRuleId", this.assignmentRuleHeader.assignmentRuleId);
+ }
+ if (this.assignmentRuleHeader.useDefaultRule) {
+ writer.writeNameValueNode("useDefaultRule", this.assignmentRuleHeader.useDefaultRule);
+ }
+ writer.writeEndElement("AssignmentRuleHeader", headerNs);
+ }
+ if (this.transferToUserId !== null) {
+ writer.writeStartElement("UserTerritoryDeleteHeader", headerNs);
+ writer.writeNameValueNode("transferToUserId", this.transferToUserId);
+ writer.writeEndElement("UserTerritoryDeleteHeader", headerNs);
+ }
+ if (this.duplicateRuleHeader !== null) {
+ writer.writeStartElement("DuplicateRuleHeader", headerNs);
+ if (this.duplicateRuleHeader.allowSave) {
+ writer.writeNameValueNode("allowSave", this.duplicateRuleHeader.allowSave);
+ }
+ if (this.duplicateRuleHeader.includeRecordDetails) {
+ writer.writeNameValueNode("includeRecordDetails", this.duplicateRuleHeader.includeRecordDetails);
+ }
+ if (this.duplicateRuleHeader.runAsCurrentUser) {
+ writer.writeNameValueNode("runAsCurrentUser", this.duplicateRuleHeader.runAsCurrentUser);
+ }
+ writer.writeEndElement("DuplicateRuleHeader", headerNs);
+ }
+ if (this.debuggingHeader !== null) {
+ writer.writeStartElement("DebuggingHeader", headerNs);
+ // Write out old style if specified
+ if (this.debuggingHeader.debugLevel) {
+ writer.writeNameValueNode("debugLevel", this.debuggingHeader.debugLevel);
+ }
+ // Write out the new style debugging categories and levels
+ if (this.debuggingHeader.debugCategories) {
+ var categories = this.debuggingHeader.debugCategories;
+ for (var i = 0; i < categories.length; i++) {
+ var catAndLevel = categories[i].split(",");
+
+ if (catAndLevel.length == 2) {
+ writer.writeStartElement("categories");
+ writer.writeNameValueNode("category", catAndLevel[0]);
+ writer.writeNameValueNode("level", catAndLevel[1]);
+ writer.writeEndElement("categories");
+ }
+ }
+ }
+ writer.writeEndElement("DebuggingHeader", headerNs);
+ }
+
+ writer.endHeader();
+};
+
+sforce.Connection.prototype.namespaceMap = [
+{ns:sforce.Connection.prototype.sforceNs, prefix:null},
+{ns:sforce.Connection.prototype.sobjectNs, prefix:"ns1"}
+ ];
+
+sforce.Connection.prototype.invoke = function(method, args, isArray, callback) {
+ return this._invoke(method, args, isArray, callback, this.namespaceMap, this.serverUrl, this.sforceNs, this.sobjectNs);
+};
+
+sforce.Connection.prototype._invoke = function(method, args, isArray, callback, namespaces, url, headerNs, sobjectNs) {
+ if (callback) {
+ if (typeof(callback) == "function") {
+ } else {
+ if (!callback.onSuccess) {
+ throw "onSuccess not defined in the callback";
+ }
+ if (!callback.onFailure) {
+ throw "onFailure not defined in the callback";
+ }
+ }
+ }
+
+ var writer = new sforce.XmlWriter();
+ writer.startEnvelope();
+ this.writeHeader(writer, headerNs);
+ writer.startBody();
+ writer.writeStartElement(method);
+
+ for (var i = 0; i<namespaces.length; i++) {
+ writer.writeNamespace(namespaces[i].ns, namespaces[i].prefix);
+ }
+
+ for (var i = 0; i < args.length; i++) {
+ var arg = args[i];
+ if (typeof(arg.value) === "undefined") {
+ throw "arg " + i + " '" + arg.name + "' not specified";
+ }
+ if (arg.value !== null) {
+ if (arg.isArray && !arg.value.push) {
+ throw "arg " + i + " '" + arg.name + "' is an array. But passed in value is not an array";
+ }
+ if (!arg.isArray && arg.value.push) {
+ throw "arg " + i + " '" + arg.name + "' is not an array. But passed in value is an array";
+ }
+ }
+ if (arg.value === null) {
+ this.writeOne(writer, arg.name, null, sobjectNs);
+ } else if (arg.value.push) { //this is an array
+ for (var j = 0; j < arg.value.length; j++) {
+ var obj = arg.value[j];
+ if (!obj) {
+ throw "Array element at " + j + " is null.";
+ }
+ this.writeOne(writer, arg.name, obj, sobjectNs);
+ }
+ } else {
+ this.writeOne(writer, arg.name, arg.value, sobjectNs);
+ }
+ }
+ writer.writeEndElement(method);
+ writer.endBody();
+ writer.endEnvelope();
+ if (sforce.debug.trace) {
+ sforce.debug.log("Request: server- " + url);
+ sforce.debug.logXml(writer.toString());
+ }
+ var transport = new sforce.SoapTransport();
+ return transport.send(url, writer, isArray, callback);
+};
+
+
+/* QueryResultIterator */
+
+sforce.QueryResultIterator = function(queryResult) {
+ this.queryResult = queryResult;
+ this.index = 0;
+ this.records = this.queryResult.getArray("records");
+};
+
+sforce.QueryResultIterator.prototype.hasNext = function() {
+ if (this.records.length > this.index) {
+ return true;
+ }
+ if (this.queryResult.queryLocator !== null) {
+ this.queryResult = sforce.connection.queryMore(this.queryResult.queryLocator);
+ this.records = this.queryResult.getArray("records");
+ this.index = 0;
+ }
+ if (this.records.length > this.index) {
+ return true;
+ } else {
+ return false;
+ }
+};
+
+sforce.QueryResultIterator.prototype.next = function() {
+ if (this.records.length > this.index) {
+ var result = this.records[this.index];
+ this.index++;
+ return result;
+ } else {
+ throw "Index out of bound : " + this.index;
+ }
+};
+
+
+/* Email */
+
+
+sforce.Email = function() {
+};
+
+sforce.Email.prototype = new sforce.Xml("messages");
+
+sforce.MassEmailMessage = function() {
+};
+
+sforce.MassEmailMessage.prototype = new sforce.Xml("messages");
+sforce.MassEmailMessage.prototype._xsiType = "MassEmailMessage";
+
+
+
+sforce.SingleEmailMessage = function() {
+};
+
+sforce.SingleEmailMessage.prototype = new sforce.Xml("messages");
+sforce.SingleEmailMessage.prototype._xsiType = "SingleEmailMessage";
+
+
+
+/* ProcessRequest */
+
+
+sforce.ProcessRequest = function() {
+};
+
+sforce.ProcessRequest.prototype = new sforce.Xml("actions");
+
+sforce.ProcessSubmitRequest = function() {
+};
+
+sforce.ProcessSubmitRequest.prototype = new sforce.Xml("actions");
+sforce.ProcessSubmitRequest.prototype._xsiType = "ProcessSubmitRequest";
+
+
+sforce.ProcessWorkitemRequest = function() {
+};
+
+sforce.ProcessWorkitemRequest.prototype = new sforce.Xml("actions");
+sforce.ProcessWorkitemRequest.prototype._xsiType = "ProcessWorkitemRequest";
+/* set up connection */
+sforce.connection = new sforce.Connection();
+
+var UserContext = (typeof window.UserContext != "undefined") ? window.UserContext : {
+ siteUrlPrefix : "",
+ getUrl : function (url) {
+ // fix URL for sites with prefixes
+ if (typeof url == "undefined" || typeof UserContext.siteUrlPrefix == "undefined" || !UserContext.siteUrlPrefix)
+ return url;
+
+ if (url.indexOf('/') != 0)
+ return url;
+
+ if(url.indexOf(UserContext.siteUrlPrefix) == 0)
+ return url;
+
+ return UserContext.siteUrlPrefix + url;
+ }
+};
+
+if (typeof(__sfdcSiteUrlPrefix) != "undefined") {
+ UserContext.siteUrlPrefix = __sfdcSiteUrlPrefix;
+}
+
+sforce.connection.serverUrl = (typeof window.UserContext != "undefined") ? UserContext.getUrl("/services/Soap/u/51.0") : "/services/Soap/u/51.0";
+
+if (typeof(__sfdcSessionId) != "undefined") {
+ sforce.connection.sessionId = __sfdcSessionId;
+}
diff --git a/force-app/main/default/staticresources/connection20.resource-meta.xml b/force-app/main/default/staticresources/connection20.resource-meta.xml
new file mode 100644
index 0000000..aa06dd8
--- /dev/null
+++ b/force-app/main/default/staticresources/connection20.resource-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">
+ <cacheControl>Public</cacheControl>
+ <contentType>application/x-javascript</contentType>
+</StaticResource>
--
Gitblit v1.9.1