Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, April 27, 2024 
 
slxdeveloper.com Community Forums  
   
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!
 External Development Forums - General External Development
Forum to discuss general external development topic (related or not to SalesLogix development). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to General External Development | New ThreadView:  Search:  
 Author  Thread: Need help: Execute a Script inside of SalesLogix from C#
Thomas
Posts: 8
 
Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Jan 09 1:22 PM
I'm a beginner of programming, and i will try some idea's with .Net and SLX, i found a lot of things for programming in SLX but nothing, where i can call a script with params from outside (my own programm)
i will give you a small example:
i will write some things in an windows application, and with a button i will call a script inside of SageLogix and give the script some params from my app

How can i do this?
I found a lot of classes, but no class have an function, where i can call a script with or without params

can you give me a little example, what i can write?

thx very much
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 09 11:33 PM
Hello guys,
i try to start a script from an external application (written in C#) to execute a vb-script inside of SalesLogix 7.2.
To give them the params i used at my first time Global-Variables, thats ok,
i think its for small Variables ok, but for a long text, its not the right.
I try to understand the way with: pass a reference to the script, but
i didnt understand this.
Can somebody give me an example how i can do this?

thx
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 6:14 AM
Hello Guys,
I am use C#,
i try the following lines to call an Script:

1. SalesLogix.SlxApplication slxapp = new SlxApplicationClass();
2. MainView mv = slxapp.MainViews.Add("Personal:TestScript_One", TxMainViewStyle.mvsDefault, false);
3. object dv = mv.DetailsView;

??????????

i found this idea by some scripts inside of SLX, which uses the following Code:

1. Dim mv, objDetail
2. Set mv = Application.MainViews.Add("Personal:TestScript_One", 0, false)

3. Set objDetail = mv.DetailsView

4. objDetail.Script.TestFunction param1, param2

How can i realize the last line (line 4.) from the inside script of SLX,
in an C# line of my Code?

Can anyone help me?????? Please!!
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 12:24 AM
An easy way would be to pull the code into a script plugin (instead of part of the script in the form itself (this new script plugin could be added back to the form to be used as an include script, rather than having teh code inline). Then add a Sub Main to the script plugin to call the appropriate method in the script.

Then it could be executed via BasicFunctions.DoInvoke. Any needed params could be passed to the Sub Main as globals. It would look something like this:

-- C# Code --

SalesLogix.SlxApplication slxapp = new SalesLogix.SlxApplicationClass();
// optionally set params
slxapp.GlobalInfo.Add("MyParam", "Some value");
// now execute the script
slxapp.BasicFunctions.DoInvoke("ActiveScript", "System:MyScript");
Marshal.ReleaseComObject(slxapp);


-- SLX Script Code --

Sub Main
MyMethod Application.GlobalInfo("MyParam")
End Sub

Sub MyMethod(MyParam)
MsgBox "I am doing something with the MyParam value: " + MyParam
End Sub


Does that make sense? In the Form that this code was originally a part of, you'll just add this new script as an include script, now it will look for the defined methods there and all will be good.

-Ryan
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 4:09 PM
Hello Ryan,
thx for response.
I try this, but it comes another Problem,
in the Debug-modus with VS 2008 an the steps before i came
to the line with:
slxapp.GlobalInfo.Add("MyParam", "my Value");

the information i write in the value, it works,
but if the debugger comes to this line,
he told me in the debug-window
that the variable with the value create an:
ComException

did you know, why this could be?

Regards Thomas
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 5:03 PM
Hi Thomas,

What does your code look like?

-Ryan
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Jan 09 4:55 AM
Hello Ryan,
sorry, the mistake is on my side,
because i delete the variable before i create the GlobalInfo
thats why the Exception comes

But i have another question, if i want to start a form
i didn't write like this right?:
slxApp.BasicFunctions.DoInvoke("ActiveScript", "System:fromoutside_form");

i have to write like this?:
slxApp.BasicFunctions.DoInvoke("Form", "System:fromoutside_form");

i don't know it, because the "ActiveScript" i understand,
but for an Form? only "Form" ?

thx for response
Regards
Thomas
[Reply][Quote]
John H. Hedges
Posts: 62
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Jan 09 10:12 AM
Quote:
i don't know it, because the "ActiveScript" i understand, but for an Form? only "Form" ?

Yes, that's the correct syntax for invoking a form. But you should only invoke a form from an external application if the form is meant to be opened as a modal dialog box, with no "entity context" - in other words, a "manage form" that isn't bound to something like Accounts or Contacts.

If it's a data form, a MainView, or a non-modal window, it would probably be a lot easier to invoke a script instead, and have the script open the form in its proper state and context.
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Jan 09 12:31 PM
Hello John,
is the only way, to call an "Form" or "ActiveScript" with params,
that i use GlobalInfo?
Or exists another way to call something inside of SLX with params,
without GlobalInfo?

Can you answer this question?

Regards,
Thomas
[Reply][Quote]
John H. Hedges
Posts: 62
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Jan 09 2:32 PM
Hmm... Let's just say it's the most reliable way!

There are other ways you could *try* doing it that would allow parameters within the function call itself (such as the old ClientObjix "DoBasic" command, or the IManaged.Run() method with the new .NET forms), but those methods would probably be much more involved, and I don't want to confuse the issue.

You say the problem is that the data being passed into SLX is too big - how big is it, exactly? It would have to be REALLY big to cause a problem on most machines, and it's unlikely you'll exceed the limits of the Variant datatype in any case, but I suppose anything is possible... One thing you might consider, though it's a bit advanced, is to have your external application create an OLE interface of some sort that encapsulates this data, and then just pass the interface reference into SLX's GlobalInfo. If you can get that to work, SLX would be accessing the original data "by reference," not a copy (i.e., "by value"). In fact, a "quick 'n' dirty" way of doing essentially the same thing might be to save the huge piece of data to a file, put the filename into GlobalInfo, and then have the SLX script open the file.

I myself have never had to pass anything so huge into SLX as to make that sort of approach necessary, though.
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Feb 09 1:26 PM
Hello John, hello Ryan,
it works all very fine, but now i have another problem.
I use the following VBScript inside of SLX to call an extern Program:

Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & & Chr(34) & " " & param, 1, false
Set shell = Nothing

if in the param an string i write, all works very fine.

But now, i will try to tell my problem,

in an while-loop i read all AccountID and write this in the param as an string like the following:

If accRS.RecordCount > 0 Then

accRS.MoveFirst
param = accRS.Fields("AccountID")
accRS.MoveNext
While Not (accRS.EOF)
param = param & " " & accRS.Fields("AccountID")
accRS.MoveNext
WEnd
End If

this loop works fine , but if i want to call the ext program with the new param
SLX brings an error with the following message:
"Permission denied"

What is wrong?

in the ext-Program it only write the param on an Console
not more.

What can i do, that i can set the needed Permissions for send the param
to my ext-program?

I hope somebody can help me!
[Reply][Quote]
John H. Hedges
Posts: 62
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Feb 09 2:42 PM
I'm fairly certain there's a limit to the length of a command-line argument in a Shell() statement, and I wouldn't be surprised if it's 256 characters. How many AccountID's are getting passed this way? What's more, unless you put quotes around the whole string, they're going to be passed as individual parameters, not as one big list. (And there are several better ways to do that regardless.)

Also, I assume the name of the program would normally be between the two Chr(34)'s...

>> shell.Run Chr(34) & & Chr(34) & " " & param, 1, false

Without knowing more about what you're trying to actually do, that's the only thing I can see just by looking at that code there.
[Reply][Quote]
Thomas
Posts: 8
 
Re: Need help: Execute a Script inside of SalesLogix from C#Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 09 11:34 PM
Hello John,
you are right, the problem is that i only can use 256 character .
Can i say with an extra command that the string could be bigger than 256 characters?
Now i take the way that i create an text-file where i write the information, if the string bigger than 256 characters.
Yeah, sometimes the accountid's are longer than 256 characters.
With the A letter i have 10 Accounts (that works fine)
But with the M letter i have 22 Accounts, and that doesnt work, here comes the error-message: "Permission denied"

Gives another way?

Regards thomas
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 4/27/2024 8:37:25 AM