SOURCE

function load()
{
debugger
	Xrm.Page.data.process.addOnStageChange(function ()
	{
		var nextStageName = Xrm.Page.data.process.getActiveStage().getName();
		switch (nextStageName)
		{
			case "情報収集":
				break;
			case "概算見積提示まで":
debugger
				checkCofirmField("cr3bb_overall_confirmation1")
				break;
			case "入札公示まで":
				checkCofirmField("cr3bb_overall_confirmation2")
				break;
			case "開札まで":
				checkCofirmField("cr3bb_overall_confirmation3")
				break;
		}
	})
}

function checkCofirmField(fieldName)
{
	var fieldVal = Xrm.Page.getAttribute(fieldName).getValue();
	if (fieldVal == 2 || fieldVal == 3)
	{
		return true;
	}
	else
	{
        Xrm.Page.data.process.movePrevious(function(){
                Xrm.Utility.showProgressIndicator("次の段階に進むことはできません");
                setTimeout(function(){
                    Xrm.Utility.closeProgressIndicator();
                },3000)
            }
        );

		return false;
	}
}



function ProcessStatusChange(){

	Xrm.Page.data.process.addOnPreStageChange(function (context)
	{
		
		var objProcessContext=context.getEventArgs();
		var nextStageName = Xrm.Page.data.process.getActiveStage().getName();
		switch (nextStageName) {
            case "情報収集":
                var cr3bb_information_gathering1 = Xrm.Page.getAttribute("cr3bb_information_gathering1").getValue()
                if (cr3bb_information_gathering1 == null) {
                    ErrorMessage("タスク情報が未入力のため、次の段階へ進むことはできません。");
                    //objProcessContext.preventDefault()
                }


                break;
            case "概算見積提示まで":
                //var cr3bb_proposal_wbs_creation1=Xrm.Page.getAttribute("cr3bb_proposal_wbs_creation1").getValue()
                var cr3bb_proposal_policy_meeting1 = Xrm.Page.getAttribute("cr3bb_proposal_policy_meeting1").getValue()
      var cr3bb_our_superiority = Xrm.Page.getAttribute("cr3bb_our_superiority").getValue()
                var cr3bb_estimated_budget_tips1 = Xrm.Page.getAttribute("cr3bb_estimated_budget_tips1").getValue()
                if (cr3bb_proposal_policy_meeting1 == null || cr3bb_our_superiority == null || cr3bb_estimated_budget_tips1 == null) {
                    ErrorMessage("タスク情報が未入力のため、次の段階へ進むことはできません。");
 //objProcessContext.preventDefault();
                }
                break;
            case "入札公示まで":
                var cr3bb_proposal_wbs_creation2 = Xrm.Page.getAttribute("cr3bb_proposal_wbs_creation2").getValue()
                var cr3bb_contract_consult = Xrm.Page.getAttribute("cr3bb_contract_consult").getValue()
                var cr3bb_lease_company_coordination1 = Xrm.Page.getAttribute("cr3bb_lease_company_coordination1").getValue()
                var cr3bb_order_policy_deliberation = Xrm.Page.getAttribute("cr3bb_order_policy_deliberation").getValue()
                var cr3bb_submissions = Xrm.Page.getAttribute("cr3bb_submissions").getValue()
                if (cr3bb_proposal_wbs_creation2 == null || cr3bb_contract_consult == null || cr3bb_lease_company_coordination1 == null || cr3bb_order_policy_deliberation == null || cr3bb_submissions == null) {
                    ErrorMessage("タスク情報が未入力のため、次の段階へ進むことはできません。");
                    //objProcessContext.preventDefault()
                }
                break;
            case "開札まで":
                var cr3bb_contract_consult_exceptional_condition = Xrm.Page.getAttribute("cr3bb_contract_consult_exceptional_condition").getValue()
                var cr3bb_professional_document_creation = Xrm.Page.getAttribute("cr3bb_professional_document_creation").getValue()
                var cr3bb_order_conditions_deliberation = Xrm.Page.getAttribute("cr3bb_order_conditions_deliberation").getValue()
                var cr3bb_proposal_preparation = Xrm.Page.getAttribute("cr3bb_proposal_preparation").getValue()
                var cr3bb_submission_material = Xrm.Page.getAttribute("cr3bb_submission_material").getValue()
                var cr3bb_entry_submission_documents = Xrm.Page.getAttribute("cr3bb_entry_submission_documents").getValue()
                if (cr3bb_contract_consult_exceptional_condition == null || cr3bb_professional_document_creation == null || cr3bb_order_conditions_deliberation == null || cr3bb_proposal_preparation == null || cr3bb_submission_material == null|| cr3bb_entry_submission_documents == null) {
                    ErrorMessage("タスク情報が未入力のため、次の段階へ進むことはできません。");
                   // objProcessContext.preventDefault()
                }
                break;
        }
	
	})
	Xrm.Page.data.process.addOnProcessStatusChange(function(){//更改结束的状态
debugger
var StageName = Xrm.Page.data.process.getActiveStage().getName();
if(StageName=="開札まで")
{
    var fieldVal = Xrm.Page.getAttribute("cr3bb_overall_confirmation4").getValue();
     if (fieldVal == 2 || fieldVal == 3) {
         var cr3bb_contract_consult_exceptional_condition = Xrm.Page.getAttribute("cr3bb_contract_consult_exceptional_condition").getValue()
                var cr3bb_professional_document_creation = Xrm.Page.getAttribute("cr3bb_professional_document_creation").getValue()
                var cr3bb_order_conditions_deliberation = Xrm.Page.getAttribute("cr3bb_order_conditions_deliberation").getValue()
                var cr3bb_proposal_preparation = Xrm.Page.getAttribute("cr3bb_proposal_preparation").getValue()
                var cr3bb_submission_material = Xrm.Page.getAttribute("cr3bb_submission_material").getValue()
                var cr3bb_entry_submission_documents = Xrm.Page.getAttribute("cr3bb_entry_submission_documents").getValue()
                if (cr3bb_contract_consult_exceptional_condition == null || cr3bb_professional_document_creation == null || cr3bb_order_conditions_deliberation == null || cr3bb_proposal_preparation == null || cr3bb_submission_material == null|| cr3bb_entry_submission_documents == null) {
                    ErrorMessage("タスク情報が未入力のため、終了むことはできません。");
                   // objProcessContext.preventDefault()
Xrm.Page.data.process.reactivateProcess();
return false;
                }
        return true;
    }else{
ErrorMessage("終了むことはできません。");
Xrm.Page.data.process.reactivateProcess();

return false;
}
}
})
}

function ErrorMessage(message){
alert(message)
	
}
console 命令行工具 X clear

                    
>
console