Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Regular Contributor
Kennethg
Posts: 53
Registered: 02-11-2009
0

CommandButton1

 We have a custom button in "Work Order Maintenance" called "Goto Complete". Basicly it just opens the "Completion Entry" window. What i'm trying to do is have it auto fill the "txtWorkOrderNo [SOTAMaskedEdit]" field with the WorkOrderNo from "Work Order Maintenance" window. Below is the code i'm using. Thanks!

 

Sub CommandButton1_Click
      Set WshShell = CreateObject("WScript.Shell")
   WshShell.Run ("C:\Windows\system32\BusinessDesktopLoader.exe /T570753031 " + Form.Controls("txtWorkOrderNo").Text)
      
End Sub

Regular Contributor
Kennethg
Posts: 53
Registered: 02-11-2009
0

Re: CommandButton1

Nobody has any ideas? The break... or were it seems to fail is after "WshShell.Run ("C:\Windows\system32\BusinessDesktopLoader.exe /T570753031 "" the "+ Form.Controls("txtWorkOrderNo").Text)" isn't sending text to the next screen. It's not erroring out. I put "msgbox Form.Controls("txtWorkOrderNo") at the end of the code and it returns the WorkorderNo in a message box.

 

There is around a 2 second delay between windows.. I think it's sending the Workorderno but there just isn't a window to put it in. I also tried puting a delay between the windows.. but still no go. I used "wscript.sleep (2000)" but it errors out saying it doesn't understand the command "wscript.sleep".  This is what i've tried.

 

Sub CommandButton1_Click
      Set WshShell = CreateObject("WScript.Shell")
   WshShell.Run ("C:\Windows\system32\BusinessDesktopLoader.exe /T570753031 " )

   wscript.sleep (2000)

   Form.Controls("txtWorkOrderNo").Text)

 

End Sub

 

Sage Employee
dbcoles
Posts: 107
Registered: 12-04-2008
0

Re: CommandButton1

I don't think you can just add the value like that. When we launch applications with context, we send the information in an XML string and call a drill around method. I don't know the exact signature of what we send, but I'll forward along the question to see if this is do-able.

Regular Contributor
Kennethg
Posts: 53
Registered: 02-11-2009
0

Re: CommandButton1

Thanks dbcoles! I really hope it is do-able.

Sage Employee
manookian
Posts: 84
Registered: 07-06-2009
0

Re: CommandButton1

Sample to launch AR Customer Maintenance with specific customer context:

 

Private Declare Function AllowSetForegroundWindow Lib "user32" (ByVal dwProcessID As Long) As Boolean
Private Const ASFW_ANY = -1

Private Sub Command1_Click()
    Dim bRetVal As Boolean
    bRetVal = AllowSetForegroundWindow(ASFW_ANY)
    Err.Clear

    Dim CustID As String
    CustID = Me.txtCustomerID.Text
   
    Dim xml As String
    xml = "<Environment><Context><CustID Value=""" & CustID & """ /></Context></Environment>"

 

    Dim TaskID As Long
    TaskID = 83952612
   
    Dim NavigateTo As Object
    Set NavigateTo = moClass.moFramework.LaunchTask(TaskID, EFW_TF_AUTOSHUTDN + EFW_TF_AUTOLOADUI + EFW_TF_AUTODISPLAYUI + EFW_TF_STANDALONE, 0, 0, 0, xml)
End Sub

 

Sage Employee
manookian
Posts: 84
Registered: 07-06-2009

Re: CommandButton1

After looking at this specific issue here is the code you want:

 

In mfzdb001.frm:

Private Declare Function AllowSetForegroundWindow Lib "user32" (ByVal dwProcessID As Long) As Boolean
Private Const ASFW_ANY = -1

Private Sub Command1_Click()
    Dim bRetVal As Boolean
    bRetVal = AllowSetForegroundWindow(ASFW_ANY)
    Err.Clear

    Dim WorkOrder As String
    WorkOrder = Me.txtWorkOrderNo.Text
   
    Dim xml As String
    xml = "<Environment><Context><WorkOrderNo Value=""" & WorkOrder & """ /></Context></Environment>"

    Dim TaskID As Long
    TaskID = 570753031
   
    Dim NavigateTo As Object
    Set NavigateTo = moClass.moFramework.LaunchTask(TaskID, EFW_TF_AUTOSHUTDN + EFW_TF_AUTOLOADUI + EFW_TF_AUTODISPLAYUI + EFW_TF_STANDALONE, 0, 0, 0, xml)
End Sub

 

In mfzdg001.cls:

Public Sub NavigateTo(ByVal xml As String)
    On Error Resume Next

    Dim sWorkOrderNo As String
    sWorkOrderNo = Trim(GetFromXML(xml, "WorkOrderNo"))
   
    If Len(sWorkOrderNo) > 0 Then
        mfrmMain.txtWorkOrderNo.Text = sWorkOrderNo
        mfrmMain.bIsValidID
    End If
    
    Err.Clear
 End Sub