Products A-Z All Services Can't find what you're looking for? Chat Live!
Products A-Z Can't find what you're looking for? Chat Live!
Can't find what you're looking for? Chat Live!
Hi Guys,
Wondering if you can help.
I have written a web service for Net Community to talk to RE and update the user Solicit Codes.
I have two questions:
1. To get access to the solicit code code table objects I had to modify the IBBSessionContext cast in the WebService from the one shown in the NC samples
Blackbaud.PIA.RE7.BBInterfaces.IBBSessionContext
to the one shown in the REAPI help page samples Blackbaud.
PIA.RE7.BBREAPI.IBBSessionContext
The context object used in the Net Community code samples is more limited in scope. It seems to work but I am concerned. Is this a valid modification? Can anyone see any issues with this?
2. While attempting to do a CRecord.save() I get the following exception:
System.Exception: Error saving user solicit codes. Error in Save: Objects in Read-Only mode cannot be saved or deleted
I am not sure what is causing this. I tried modifying the CRecord.ReadOnly flag to true but it came up with uninitialised object errors. Is this a licensing issue or a configuration issue? Can anyone shed any light on this?
I have listed the current code below.
Thanks Michael
-----------------------------------------
Web Service Request Handler:
using System;using Blackbaud.NetCommunity.WebService.Interfaces;using Blackbaud.PIA.RE7.BBREAPI;using CurtinLinkOnlineCommon;namespace CurtinLinkOnlineWebService{ [BBNCExtensions.CustomServiceMethods.CustomServiceMethod(CurtinLinkOnlineWebServiceConstants.WebServiceGuid)] public class RequestHandler : IRequestHandler { public object GetResponse(IRequestSender sender, object request) { // "Session Context" for using The Raiser's Edge client-side API. IBBSessionContext context = (IBBSessionContext)sender.SessionContext; // Dispatch request to handlers if (request is GetRegisteredEventsRequest) { return new RegisteredEventsHandler().GetRegisteredEvents((GetRegisteredEventsRequest)request, context); } else if (request is GetMailPreferencesRequest) { return new MailPreferencesHandler().GetMailPreferences((GetMailPreferencesRequest)request, context); } else if (request is SetMailPreferencesRequest) { return new MailPreferencesHandler().SetMailPreferences((SetMailPreferencesRequest)request, context); } else { throw new Exception("Request type not handled in this service, " + request.GetType()); } } }}
Method from MailPreferencesHandler:
public SetMailPreferencesResponse SetMailPreferences(SetMailPreferencesRequest request, IBBSessionContext context) { int constituentID = 0; constituentID = request.ConstituentId; List<RESolicitCode> solicitCodes = request.RESolicitCodes; SetMailPreferencesResponse response = new SetMailPreferencesResponse(); CRecord constituent = new CRecord(); try { constituent.Init(ref context); constituent.Load(constituentID, true); // wipe all existing solicit codes foreach (CConstituentSolicitCode userSolicitCode in constituent.SolicitCodes) { constituent.SolicitCodes.Remove(userSolicitCode); } // add all the new ones foreach (RESolicitCode newSolicitCode in solicitCodes) { CConstituentSolicitCode newCode = constituent.SolicitCodes.Add(); newCode.set_Fields(ECONSTITUENT_SOLICITCODESFields.CONSTITUENT_SOLICITCODES_fld_SOLICIT_CODE, newSolicitCode.Description); } constituent.Save(); } catch (Exception ex) { throw new Exception("Error saving user solicit codes. " + ex.Message); } finally { constituent.CloseDown(); } return response; }
Hi Michael,
I can't help you with the session context question however I asked on of our RE experts about the read only issue and here is the response he gave me.
How are they accessing the cRecord object that is invoking the Save method?
Have they called the Init method and passed in the session context?
Have they loaded it with the readOnly parameter set to True?
Record.Load 1, True ‘does not allow saves
Record.Load 1, False ‘allows saves
Record.LoadByField uf_Record_Constituent_ID, “5” ‘allows saves
Beyond that, they probably should follow up with Customer Support.
from another RE expert
I would also have them make sure they test as Supervisor (if they aren’t already), just to make sure there are no security settings that don’t allow the specific user to save bio information.
Thomas DeMille:Have they loaded it with the readOnly parameter set to True?
Thanks Thomas, changing the record.load parameters fixed the issue :)
All the REAPI documention I could find was on extracting data and not saving data and as a result I wasn't aware of the flag in the load.