Workflow Problem

Hi All,

Plz Any body is there to solve my problem.

I have a workflow database where in some stage iam sending the document to multiple approvers(parallel) using the following code:

  1. This code is written in button to call function to split approvers list and saving in another form:

If Not createApproversDocuments(uidoc) Then

Msgbox “Error in Creating Approve Documents”

Exit Sub

End If

  1. This code will check the approvers docs and creates

Function createApproversDocuments(cdoc As NotesUIDocument) As Boolean

On Error Goto ErrorHandler

Dim ApproversList As Variant

ApproversList = Split(cdoc.FieldGetTExt(“Approvers”), “,”)

If Not Isarray(ApproversList) Then

If Not (createSingleApproverDocument(cdoc, Cstr(ApproversList))) Then

   createApproversDocument = False

Exit Function

End If

Else

For count = Lbound(ApproversList) To Ubound(ApproversList)

If Not (createSingleApproverDocument(cdoc, ApproversList(count))) Then

 createApproversDocument = False

Exit Function

End If

Next

End If

'Create Approver document for Other Approvers

createApproversDocuments = True

Exit Function

ErrorHandler:

Msgbox "Error in createApproversDocument(), Line # " & Erl & ", Message : " & Error$

createApproversDocuments = False

End Function

  1. This code will split and create docs with status and approver name in form:

Function createSingleApproverDocument(cdoc As NotesUIDocument, ApproverName As String) As Boolean

On Error Goto ErrorHandler	



Dim approverDoc As NotesDocument

Dim nam As New NotesName(ApproverName)



Set approverDoc = db.CreateDocument



approverDoc.Form = "frmApproversAction"

approverDoc.Status = "PENDING"

approverDoc.UserName = Trim(nam.Abbreviated) 

approverDoc.UpdateTime = Trim(doc.ServerTime(0))

approverDoc.ParentUNID = Trim(cdoc.FieldGetText("UNID"))

approverDoc.RFCNo = Trim(doc.RFC(0))

Call approverDoc.Save(True, False)



createSingleApproverDocument = True

Exit Function

ErrorHandler:

Msgbox "Error in Line # " & Erl & ", Message : " & Error$

createSingleApproverDocument = False

End Function

Now my problem is if example one field is there and if this field value is “Yes” it should update status as approved where iam saving in the form “frmApproversAction” above mentioned for one approver(hard coded approver name) and mail should route to all approvers. Where the person(hard coded approver) will not approve this doc if that field is Yes and remaining approvers need to approve.

Above code is working fine with field value is not selected. Only problem with the field value is Yes.

How to solve my problem. Plz help me

srini

Subject: Workflow Problem

This looks like a difficult way to accomplish the task. Looking at the code I can not see an obvious reason why it does not work. You might be trying to re-invent the wheel as well.

Our Workflo!Approval would handle the process that you describe without having to go through all that processes. Look at our demo at

http://wfs.com/workweb/wfsweblib.nsf/Src/DocSet*Notes+Net07

it might give you some ideas as to how to do this.

Subject: Workflow Problem

I found it a bit hard to understand your problem, but where do doc.ServerTime(0) and doc.RFC(0) come from, i.e. what is ‘doc’ when you are creating approverDoc? a global variable (like I imagine ‘db’ is)?

Can you explain in more detail?

Cheers

Peter

Subject: RE: Workflow Problem

Thanks Peter forresponding

These fields servertime & RFC are the fields present in the main form document. So iam getting these values from main form document and updating in form “frmapproveraction” with approverdoc. Here iam given doc=uidoc.document for getting front end values.

My problem is if the field value in main document is “XYZ” it should update the fields in “frmapproveraction” with values given in the above mentioned code for only one approver(hard coded approver) and remaining approver need to show pending

how to solve

Subject: RE: Workflow Problem

Would you need to do something like the below?

Dim approverDoc As NotesDocument

Dim nam As New NotesName(ApproverName)

dim session as new NotesSession

Set approverDoc = db.CreateDocument

approverDoc.Form = “frmApproversAction”

if doc.FieldValue(0) = “XYZ” then

if lcase(nam.Common) = lcase(session.CommonUserName) then

approverDoc.Status = “APPROVED”

else

approverDoc.Status = “PENDING”

end if

else

approverDoc.Status = “PENDING”

end if