銆愯浆銆戙€怱alesfoece銆慉pproval Process 鍦?Apex 涓殑浣跨敤

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了銆愯浆銆戙€怱alesfoece銆慉pproval Process 鍦?Apex 涓殑浣跨敤相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/htm' title='htm'>htm   mod   ini   span   use   oval   ams   meta   tps   

鎵瑰噯杩囩▼鏄竴涓鏉傜殑涓氬姟杩囩▼銆傝缁嗙殑鍐呭鍙互鍙傝€冨畼鏂规枃妗c€?/p>

鑻辨枃鐗?/a>

涓枃鐗?/a>

瀹樻柟trailhead妯″潡

鍦ˋpex涓皟鐢ˋpproval Process

鍦ˋpex涓彲浠ヤ娇鐢ㄤ互涓嬬被瀵笰pproval Process杩涜鎿嶄綔锛?/p>

  • ProcessInstance锛氬彲浠ョ敤鏉ユ煡璇㈡垨閬嶅巻Approval Process杩囩▼銆?/li>
  • ProcessInstanceHistory锛氬彧璇诲璞★紝涓嶈兘鐩存帴琚玈OQL鏌ヨ銆備唬琛ㄤ簡Approval Process杩囩▼鐨勬墍鏈夋楠ゅ拰鐩稿叧鐨勭姸鎬佷负鈥減ending鈥濈殑璇锋眰銆?/li>
  • ProcessInstanceStep锛氫唬琛ㄤ簡Approval Process杩囩▼鐨勪竴涓楠ゃ€?/li>
  • ProcessInstanceWorkitem锛氫唬琛ㄤ簡Approval Process杩囩▼鐩稿叧鐨勭姸鎬佷负鈥減ending鈥濈殑璇锋眰銆?/li>

鍦ˋpex涓彲浠ヤ娇鐢⊿OQL瀵筆rocessInstance杩涜鏌ヨ锛岃€屽浜庡叾浠栦笁涓被鐨勬煡璇竴鑸槸浣滀负瀵筆rocessInstance鏌ヨ鐨勫瓙璇彞鏉ヨ繘琛屻€?/p>

SELECT Id, (SELECT Id, StepStatus, Comments FROM Steps)
FROM ProcessInstance

涓婇潰杩欐浠g爜鍙互鏌ヨApproval Process杩囩▼鐨処d锛屽苟鏌ヨ鍏跺寘鎷殑姝ラ鐨勫悇涓睘鎬с€?/p>

SELECT Id, (SELECT Id, ActorId, ProcessInstanceId FROM Workitems)
FROM ProcessInstance

涓婇潰杩欐浠g爜鍙互鏌ヨApproval Process鐩稿叧鐨勭姸鎬佷负鈥減ending鈥濈殑璇锋眰锛圵orkitems锛夈€?/p>

SELECT Id, (SELECT Id, StepStatus, Comments FROM StepsAndWorkitems)
FROM ProcessInstance

涓婇潰杩欐浠g爜鍙互鏌ヨApproval Process杩囩▼鐨勫巻鍙茶褰曘€?/p>

SELECT Id, ActorId, ProcessInstanceId 
FROM ProcessInstanceWorkitem
WHERE ProcessInstanceId = 鈥榅XXX鈥?

涓婇潰杩欐浠g爜鍙互鏌ヨ鍜屾煇涓狝pproval Process鐨勭浉鍏崇殑鎵€鏈夌姸鎬佷负鈥減ending鈥濈殑璇锋眰銆?/p>

瀹樻柟浠g爜绀轰緥

浠ヤ笅浠g爜鎷疯礉鑷?a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm">瀹樻柟鏂囨。锛屼綔涓轰娇鐢ˋpproval Process鐨勭ず渚嬶細

public class TestApproval {
    void submitAndProcessApprovalRequest() {
        // Insert an account
        Account a = new Account(Name=鈥楾est鈥?annualRevenue=100.0);
        insert a;
           
        User user1 = [SELECT Id FROM User WHERE Alias=鈥楽omeStandardUser鈥榏;
            
        // Create an approval request for the account
        Approval.ProcessSubmitRequest req1 = 
            new Approval.ProcessSubmitRequest();
        req1.setComments(鈥楽ubmitting request for approval.鈥?;
        req1.setObjectId(a.id);
        
        // Submit on behalf of a specific submitter
        req1.setSubmitterId(user1.Id); 
        
        // Submit the record to specific process and skip the criteria evaluation
        req1.setProcessDefinitionNameOrId(鈥楶TO_Request_Process鈥?;
        req1.setSkipEntryCriteria(true);
        
        // Submit the approval request for the account
        Approval.ProcessResult result = Approval.process(req1);
        
        // Verify the result
        System.assert(result.isSuccess());
        
        System.assertEquals(
            鈥楶ending鈥? result.getInstanceStatus(), 
            鈥業nstance Status鈥?result.getInstanceStatus());
        
        // Approve the submitted request
        // First, get the ID of the newly created item
        List<Id> newWorkItemIds = result.getNewWorkitemIds();
        
        // Instantiate the new ProcessWorkitemRequest object and populate it
        Approval.ProcessWorkitemRequest req2 = 
            new Approval.ProcessWorkitemRequest();
        req2.setComments(鈥楢pproving request.鈥?;
        req2.setAction(鈥楢pprove鈥?;
        req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        
        // Use the ID from the newly created item to specify the item to be worked
        req2.setWorkitemId(newWorkItemIds.get(0));
        
        // Submit the request for approval
        Approval.ProcessResult result2 =  Approval.process(req2);
        
        // Verify the results
        System.assert(result2.isSuccess(), 鈥楻esult Status:鈥?result2.isSuccess());
        
        System.assertEquals(
            鈥楢pproved鈥? result2.getInstanceStatus(), 
            鈥業nstance Status鈥?result2.getInstanceStatus());
    }
}

以上是关于銆愯浆銆戙€怱alesfoece銆慉pproval Process 鍦?Apex 涓殑浣跨敤的主要内容,如果未能解决你的问题,请参考以下文章

銆愯浆銆?springBoot---蹇€熷垱寤洪」鐩紝鍒濊Вjackson

銆愯浆銆?springboot鏁村悎redis-sentinel鏀寔Cache娉ㄨВ

銆愯浆銆戝悓婧愮瓥鐣ュ拰璺ㄥ煙璇锋眰瑙e喅鏂规

銆愯浆銆慔Base涓璟ookeeper锛孯egionServer锛孧aster锛孋lient涔嬮棿鍏崇郴

銆怉tCoder銆慉GC030

銆愬墤鎸噊ffer銆戙€愭爤銆?0.鍖呭惈min鍑芥暟鐨勬爤