Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..
1352 views

Validating Attachment using RuleSet

Jump to solution

Hi

Change Management: 

I have a requirement to validate whether atatchment is present or not before going to Approval phase. For this i have created a RuleSet that runs during the transition between the 2 phases. This RuleSet runs a  javascript where i am querying the SYSATTACHMENT table and based on this query displaying a validation message.

 

There is a limitation to this, say user upload a document, (Change is not saved yet) and then clicks the button "Request Approval", at this time Ruleset is invoked- the query returns no record because attachment is not saved to SYSATTACHMENT table yet. User will have to attach the doc then save and then click "Request Approval" button.

 

Is there a way around this limitation ?

 

Thank You

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

I found a workaround for this issue.

 

1) Created a new WorkflowPhase called "Pre Manager Validation"

 

2) Created a new "After Update" trigger on "cm3r" table

 

3) In the trigger based on condition if previous phase is "Build" and new phase is "Pre Manager Validation" query
     attachment table to see attachment exist. If yes set a global variable to true else set it to false

 

4) Based on this global variable set automatic transition between the phases "Build"-->"Pre Manager Validation"
     -->"Manager Approval"

 

5) In the new phase "Pre Manager Validation", in the Initialization tab call a rule set which calls a process
     if the global variable is true

6) In the process if global variable is true show a message using "mb.ok" and then clean up the variable in Post
     Expression tab

View solution in original post

8 Replies
Highlighted
Absent Member.
Absent Member.

Cannot surely say about PD but as per standard SM design attachment will always be added at last stage of addition of record in system. Attachment are handled by hardcoded independent Java applet and do not come under classic tailoring options.

Expecting same will be apply to PD as well.

 

As you have also confirmed that SYSATACHMNT record is getting added after all validation and submit of record so looks difficult to put any restriction n attachments.

 

Hope someone else have managed to found the workaround for same.

____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

During trnasition i am using a new Rule which calls the change.update.save process, so that the change saves first before rest of my RuleSets are called. But this is giving me error like below

 

 

Syntax Error: unterminated String Literal

Could not process script

Action of is invalid (se.base.method)

 

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

You may instead want to not display request approval transition until after an attachment has been added and the record saved. You could run the check on record display to return a flag (e.g. "$attachmentExists") and update the condition the transition condition to include that variable.

----------------------------------------------------
Kudos - what, where, how, and why
Want Good Answers? Ask Good Questions...
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

But there is problem to this approach--> What if user atatched the document and saves the change record-->Request Approval button appears, user could remove the attachment and then clck the request Approval button. At this time i  will not be able to validate the doc is present in SYSATTACHMENT table, because the doc still exist in SYSATTACHMENT (it is not removed until change is saved. and by the time change is saved it would have moved to Approval phase)

 

Thanks

0 Likes
Highlighted
Established Member..
Established Member..

A possible workaround here is that you create a custom table and let your user upload the attachment to that table. It is not so comfortable, the user has to click more but this way you can have your validations.

Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

I found a workaround for this issue.

 

1) Created a new WorkflowPhase called "Pre Manager Validation"

 

2) Created a new "After Update" trigger on "cm3r" table

 

3) In the trigger based on condition if previous phase is "Build" and new phase is "Pre Manager Validation" query
     attachment table to see attachment exist. If yes set a global variable to true else set it to false

 

4) Based on this global variable set automatic transition between the phases "Build"-->"Pre Manager Validation"
     -->"Manager Approval"

 

5) In the new phase "Pre Manager Validation", in the Initialization tab call a rule set which calls a process
     if the global variable is true

6) In the process if global variable is true show a message using "mb.ok" and then clean up the variable in Post
     Expression tab

View solution in original post

Highlighted
Established Member..
Established Member..

Looks fine this way.

Why do you need a trigger record and global variable when you have a new phase? You can call your validation process from the workflow, set a thread variable and use it in your automatic transition.

0 Likes
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Say i have i 2 phases "Build" and "Manager Approval". Now i am in phase "Build", i have an attachment, now i remove the attachment and without hitting save button i click the button "Request Manager Approval"

 

What happens is this sequence

 

1) phase changes from "Build" to "Manager Approval"

2) Attachment is removed from the SYSATTACHMENT table (because i removed the attachment from attachment tab)

 

So my validation during the transtion fails because during the transition the attachment is still present in the SYSATTACHMENT table. It is only after the phase changes that the SYSATTACHMENT table is updated.

 

Hope this helps

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.