Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Thursday, January 23, 2020 
 
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 - ASP/ASP.NET/Web Services/Other
Forum to discuss building external web applications for SalesLogix. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to ASP/ASP.NET/Web Services/Other | New ThreadView:  Search:  
 Author  Thread: SLX8/SData: Unable to call custom Business Rule per SData
FhgAdmin
Posts: 3
 
SLX8/SData: Unable to call custom Business Rule per SDataYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Aug 14 5:42 AM

Hi,


could someone please help me to solve the following problem, which i´ve at the moment: First of all i create a web service for the purpose of updating and then merging duplicates of given account per SData. Updating works fine. Merging duplicates of given account causes unknowable exception and frustrated me a lot Innocent I try to call the custom business rule like this:         


            bool retVal = false;
            string OpName = "MergeAccounts";
            string DuplicateIds = string.Join(",", SubsequentDuplicateIds);

            try
            {
                SDataServiceOperationRequest sreq = new SDataServiceOperationRequest(SDataServant)
                {
                    ResourceKind = SDataResourceKind.Accounts,
                    OperationName = OpName
                };

                sreq.Entry = new AtomEntry();

                sreq.Entry.SetSDataPayload(
                    new SDataPayload
                    {
                        ResourceName = "Account" + sreq.OperationName,
                        Namespace = "http://schemas.sage.com/dynamic/2007",
                        Values =
                        {
                            {"request",new SDataPayload
                                {
                                    Values =
                                    {
                                        {"AccountID", headerAccountId},
                                        {"EntityIDs", DuplicateIds}
                                    }
                                }
                            }
                        }
                    }
                );

                AtomEntry result = sreq.Create();
                var res = (SDataPayload)result.GetSDataPayload().Values["response"];
                retVal = res.Values["Result"].ToString().ToLower().Equals("true");
            }

The custom business rule:               


                using (ISession session = new Sage.Platform.Orm.SessionScopeWrapper(true))
                {
                    try
                    {
                        string[] DuplicateIDs = EntityIDs.Split(new char[] { ',' });
                        Type mergeType = typeof(Sage.Entity.Interfaces.IAccount);
                        //bool success = false;

                        if (DuplicateIDs != null)
                        {
                            foreach (string sourceEntityId in DuplicateIDs)
                            {
                                MergeArguments SessionMergeArguments = new MergeArguments();
                                SessionMergeArguments.SourceEntityId = sourceEntityId;
                                SessionMergeArguments.SourceEntityType = mergeType;
                                SessionMergeArguments.TargetEntityId = AccountID;
                                SessionMergeArguments.TargetEntityType = mergeType;
                                SessionMergeArguments.MergeProviderType = mergeType;

                                MergeProvider sessionMergeProvider =
                                    (MergeProvider)MergeArguments.GetMergeProvider(SessionMergeArguments);
                                sessionMergeProvider.RecordOverwrite = MergeOverwrite.targetWins;

                                IAccount myaccount = (IAccount)SessionMergeArguments.MergeProvider.Target.EntityData;

                                if (myaccount.MergeAccount(SessionMergeArguments.MergeProvider))
                                {
                                    string entityId = SessionMergeArguments.MergeProvider.Source.EntityId;
                                    IPersistentEntity duplicateAccount =
                                        Sage.Platform.EntityFactory.GetById(mergeType, entityId) as IPersistentEntity;
                                    duplicateAccount.Delete();

                                    result = "Success";
                                }
                            }
                        }
                    }
                    catch (ApplicationException e)
                    {
                        result = e.Message;
                    }
                }

The problem will be caused of (MergeProvider)MergeArguments.GetMergeProvider(SessionMergeArguments) - the system gives the Result "Error getting merge configuration." back. I dont know why and dont know how to help me now. Testing the method MergeAccounts(IAccount account, string AccountID, string EntityIDs, string out result) in SLX-Context does not cause problem, i.e. creating a button binding to the (custom) business rule on click action.


It would be very nice when someone of you could tell me, what i have implemented wrongly. Thanks a lot for your help in adv!


 

[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 © 2020 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): 1/23/2020 7:53:24 PM