2 Replies Latest reply: Apr 19, 2012 12:50 PM by user731175 RSS

    Pre-defined validator vs Custom validator

    user731175
      I have a requirements where I need to validate previous version of material spec whether it is appoved or not. If not, then do not allow any user to create new version of that material spec. Wondering if this can be achieved using our pre-defined validator or should we go with custom validator.

      Thanks
      Joseph
        • 1. Re: Pre-defined validator vs Custom validator
          Ron M-Oracle
          Since the current specification does not have a property holding the previous versions of the specification, you have to look that up yourself through a database query. A custom validator would be your only option to do this.

          You have to retrieve specs from the specSummary table where the specnum is the same but the issuenum is less than (<) the current spec's issue num. If you retrieve those SpecID values, you could then use the DataManager.objectFromID method to load each spec, and then use the helper class SpecWorkflowTagEvaluator from EP2.5's PLM4PExtensionUtils to check if any of them is marked as Approved (or pass the workflow tag behavior id).

          Alternatively, and probably more efficiently, you could write the SQL where you also join against the workflow tags to determine if there are any. The following shows some of the sql, though you would have to write the rest (checking the spec number and issue number..., etc.)

          SELECT * FROM SpecSummary s
               INNER JOIN gsmWorkflowActivityTemplates iwat ON S.fkProcessTemplate = iwat.fkProcessTemplate AND S.SpecStatusID = iwat.fkWorkflowStatus
               INNER JOIN GSMWFExtendedBehaviorJoin exj ON exj.fkGSMWorkflowActivityTemplate = iwat.pkid
               INNER JOIN comLWFExtendedBehaviorTemplate beh on beh.pkid = exj.fkExtendedBehavior and beh.BehaviorID = 4 -- 4 is Is Approved - you can join against comLWFExtBehaviorTemplateML to get the tag names