The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
		
			 | 
		
			
		
			 | 
				
					Application.Managed.Run  
						Posted: 16 Sep 09 3:28 AM
					 | 
				 
					| Is there any way to use Application.Managed.Run to pass 2 arguments to a .Net Extension? At the moment we have it working passing one argument while the other is hard-coded in the .Net code.   | 
				 
					 | 
				 
			  | 
		
			 | 
				
					Re: Application.Managed.Run  
						Posted: 16 Sep 09 4:31 AM
					 | 
				 
					Hi All, not the best method but we have found an alternative. We have concatenated the two variables into 1. Passed that into the .Net Extension and then split it in .Net back to their individual variables. Not pretty but it works   | 
				 
					 | 
				 
			  | 
		
			 | 
				
					Re: Application.Managed.Run  
						Posted: 16 Sep 09 5:42 AM
					 | 
				 
					Personally, I do not use the Run method to actually do anything apart from return an instance of the .net class to SLX, which I then access as a normal COM object. 
  The below is just written from my head, so may be full of typo's etc, but I hope you get the general idea...  Obviously this may not useful for this solution but may be useful for future use.
  In .net extension: using System; using System.Runtime.InteropServices; using Sage.SalesLogix.NetExtensions; using Sage.SalesLogix.NetExtensions.SalesLogix; using Sage.SalesLogix.NetExtensions.Licensing; using Sage.SalesLogix.NetExtensions.Deployment; using System.ComponentModel;
  namespace SLXNetExtensionExample {     [ComVisible(true), ProgId("SLXNetExtensionExample.SLXWrapper")]     public class SLXWrapper : Component, IRunnable     {         ISlxApplication _slxApp;
          //Saleslogix .net extension methods         public void Initialize(ISlxApplication SlxApplication, ILicenseKeyManager LicenseKeyManager)         {             _slxApp = SlxApplication;         }
          public object Run(object[] Args)         {             return this;         }
          public Boolean DoSomething(String PassAs, Int32 ManyParameters, String AsYouLike)         {             //This is where I would actually "do some work"             return true;         } }
  Then in SLX script: Public Sub CallNetExtension(v_sWhatever, v_iParameters, v_sYouNeed)     Dim extension     Dim guid     guid = Application.Managed.Create("SLXNetExtensionExample", "SLXNetExtensionExample.SLXWrapper")     Set extension = Application.Managed.Run(guid, Nothing)     'Do whatever     If extension.DoSomething(v_sWhatever, v_iParameters, v_sYouNeed) Then         'You get the idea     End If     Set extension = Nothing     Call Application.Managed.Destroy(guid) End Sub | 
				 
					 | 
				 
			  | 
		
			 | 
				
					Re: Application.Managed.Run  
						Posted: 17 Sep 09 5:05 AM
					 | 
				 
					You can also use globals from the application object. vb
  Dim oSLX as Sage.SalesLogix.NetExtensions.SalesLogix.ISlxApplication
  and then
  oSLX.BasicFunctions.GlobalInfoFor(GlobalName)
  Much cleaner.
  ws | 
				 
					 | 
				 
			  | 
		
			 | 
				
					Re: Application.Managed.Run  
						Posted: 17 Sep 09 8:20 AM
					 | 
				 
					I pass an array as the argument.
  Here is a sample:
  sub Call_PostSaleControl     Dim SLXExt     SLXExt = Application.Managed.Create("MySLXExtension", "MySLXExtension.PostSaleStatus")     Dim rVal     Dim args
      redim args(3)     args(0) = Application.GlobalInfo.Item("OnInvoiceTeam")
      if application.BasicFunctions.CurrentOpportunityID <> "" then         args(1) = Application.BasicFunctions.CurrentViewID         args(2) = "2"         args(3) = "0"     else         args(1) = Application.BasicFunctions.CurrentViewID         args(2) = "0"     end if
      rVal = Application.Managed.Run(SLXExt, args) end sub | 
				 
					 | 
				 
			  | 
		
			 | 
				
					Re: Application.Managed.Run  
						Posted: 17 Sep 09 6:39 PM
					 | 
				 
					Originally posted by Andrew Grandin
  Is there any way to use Application.Managed.Run to pass 2 arguments to a .Net Extension? At the moment we have it working passing one argument while the other is hard-coded in the .Net code.   |  
  |  
 
  Trent is correct, pass in the args in an array (this is how it is designed to work in the first place - when you pass in a single value it actually turns into a one-item array by the time it makes it to the .NET class). Then in the Run method override in the .NET class, the Args parameter already is an array, matching up with the array values you supplied to Application.Managed.Run in the SLX script.  | 
				 
					 | 
				 
			  | 
		
			 |