3 Replies Latest reply on Dec 25, 2019 10:25 AM by Ivy Zhu-Oracle

    How to validate SCRM work flows.

    2659574

      Hi

       

      I am trying to validate SCRM work flows in PLM .But I am not able to implement.

      Could you please some one help me ?

       

      My scnario: If faclity is not added in Sourcing Approval in SCRM module  then I should show error message when approving Sourcing approval from Draft to approved.

      Condtion: SA should be assigned to  "Supplier Approval Workflow - Production Ready Packaging Material"  workflow.If SA is assinged to other workflow then it should not validate faclity field.

       

      1.Added workflow tag 1056 and 1057

      2.I have added below code in Validationsetting file.

      <ValidatorFactories>

      <add key="SCRMSAfacilityValidator" value="Singleton:SourcingApprovalHandler.SCRMSAfacilityValidatorFactory, SourcingApprovalHandler"/>

      </ValidatorFactories>

       

      <rule type="5012">

      <condition event="workflow" >

      <if type="SpecWorkflowSystemActionValidator" property="SourcedSpecification" report="false" checkTargetState="true" behaviorId="1056">

      <if type="SCRMSAfacilityValidator" report="true" />

      </if>

      <if type="SpecWorkflowSystemActionValidator" property="SourcedSpecification" report="false" checkTargetState="true" behaviorId="1057">

      <if type="SCRMSAfacilityValidator" report="true"/>

      </if>

      </condition>

      </rule>

      ---------------------------------

      3. C# CODE:

       

      namespace SourcingApprovalHandler

      {

          internal class SCRMSAfacilityValidator : BaseValidator

          {

              public override bool Validate(IValidationContext ctx)

              {

                  Assert.True(ctx.ValidationTarget is ISourcingApproval);

                  var retval = true;

                  var saf = (ISourcingApproval)ctx.ValidationTarget;

                  if (saf.fkFacilityID == null)

                  {

                     

       

       

                          ctx.AddError("Facility should not be blank.");

                          retval = false;

                    

                    

                  } return retval;

              }

          }

          public class SCRMSAfacilityValidatorFactory : XmlConfigValidatorFactoryBase

          {

              private static IValidatorFactory m_factory = new SCRMSAfacilityValidatorFactory();

              public static IValidatorFactory GetInstance() { return m_factory; }

              private SCRMSAfacilityValidatorFactory() { }

       

       

              protected override IValidator Create_Internal(XmlNode configNode)

              {

                  return new SCRMSAfacilityValidator();

              }

          }

      }