Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, May 18, 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!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: [Solved] [7.5.4] Calling BusinessRule via SData
Tim Zech
Posts: 40
 
[Solved] [7.5.4] Calling BusinessRule via SDataYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jun 15 7:02 AM

Hi there, I need to invoke a BusinessRule via SData after creating an entity. I used the approach of Mike LaSpina in this thread but without success.


Here's the code:


            SDataServiceOperationRequest sreq = new SDataServiceOperationRequest(base.NewSDataService())
            {
                ResourceKind = "licenseorders",
                OperationName = "GetDataFromServiceNetMailWrapper"
            };
            sreq.Entry = new AtomEntry();
            sreq.Entry.SetSDataPayload(
                new SDataPayload
                {
                    ResourceName = string.Format("LicenseOrder{0}", sreq.OperationName),
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values =
                    {
                        { "request", new SDataPayload
                            {
                                Values =
                                {      
                                    { "licenseorderId", licenseorder.id }
                                }
                            }                                                              
                        }
                    }
                });
            AtomEntry entry = sreq.Create();
            SDataPayload response = entry.GetSDataPayload().Values["response"] as SDataPayload;
            result = response.Values["Result"].ToString().ToLower() == "true";

I'm using the SDataCSharpClientLib v1.2.2.1335 (via NuGet)
The licenseorder has been created before and the licenseorder.id is valid.
The value licenseorderId is the parameter that the wrapper function needs to perform the wrapped operation.


It gives me the following error:
(404) Not found.


The uri being called is:
http://servername:port/sdata/slx/dynamic/-/licenseorders/$service/GetDataFromServiceNetMailWrapper


If I open http://servername:port/sdata/slx/dynamic/-/licenseorders/$service in a browser, it shows me the original BusinessRule named GetDataFromServiceNetMail but not the wrapping method.


Am I doing something wrong? Am I using the wrong version of the SDataCSharpClientLib?

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: [7.5.4] Calling BusinessRule via SDataYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jun 15 9:41 AM

IF you don't see the business rule when you list them with http://servername:port/sdata/slx/dynamic/-/licenseorders/$service then it's not seen as a business rule, which is why you're getting the 404. The code looks right.


You are sure you have a business rule named "GetDataFromServiceNetMailWrapper" and you've built & deployed the SData portal since creating it? 

[Reply][Quote]
Tim Zech
Posts: 40
 
Re: [7.5.4] Calling BusinessRule via SDataYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jun 15 2:39 AM

To be sure, I checked once again for my BusinessRule and found a little error: it waited to get an object passed to it instead of a string. Then I've deleted the contents of the build directory and the SData website, reloaded the project, made a full build and deploy and it appeared!


Now I'm getting an internal server error when running the code above, but that's probably because of bugs I produced ^^


Thanks a lot!

[Reply][Quote]
Tim Zech
Posts: 40
 
Re: [7.5.4] Calling BusinessRule via SDataYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jun 15 8:08 AM

One last thing: the value "response" in the responsePayload does not contain another payload, but a SDataSimpleCollection. So the last lines should be something like:


AtomEntry entry = sreq.Create();
SDataPayload responsePayload = entry.GetSDataPayload();
if (responsePayload != null && responsePayload.Values["response"] != null)
result = ((SDataSimpleCollection)responsePayload.Values["response"])[0].ToString().ToLower() == "true";

The code suggested by Mike LaSpina didn't work for me.

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: [7.5.4] Calling BusinessRule via SDataYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jun 15 9:23 AM

Also, there is another SData library, the DotNetSDataClient, which is newer and a bit simpler to use than the SDataCSharpClientLib. It has support for things like linq & async requests. It also has docs. You can see the docs for doing service requests using the DotNetSDataClient here http://developer.saleslogix.com/DotNetSDataClient/whitepaper/service_operations.html


Either library is valid to use, although I believe they push the DotNetSDataClient library as the preferred one to use. Just thoguht I'd mention it's out there too. It can be found on NuGet or the git repo here https://github.com/Saleslogix/DotNetSDataClient

[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): 5/18/2024 6:51:32 PM