Library Record Creation - Sage 2017 R2 - SOAP /WEBSERVICES - Question

All,

Thanks for taking the time to read this. I have an issue with creating a library record via web services.

AIM : Create a library Record -> Populate fields with data.

Sample Code:

ewarebase[] CRMBase = new ewarebase[1];//Allows reference to api

crmrecord[] libList = new crmrecord[1];

//Create a record
crmrecord aNewLibraryRecord = new crmrecord();
aNewLibraryRecord.entityname = "Library";
aNewLibraryRecord.records = new recordfield[3];
//Create fields to go in the above record
//FilePath
recordfield aFilePathField = new recordfield();
aFilePathField.name = "Libr_FilePath";
aFilePathField.value = "test";// getFilePath() ;
aFilePathField.type = crmrecordtype.@string;
aFilePathField.typeSpecified = true;

//FileName
recordfield aFileNameField = new recordfield();
aFileNameField.name = "Libr_FileName";
aFileNameField.value = getFileName();
aFileNameField.type = crmrecordtype.@string;
aFileNameField.typeSpecified = true;

//LeadID
recordfield aLibr_LeadIdField = new recordfield();
aLibr_LeadIdField.name = "Libr_LeadId";
aLibr_LeadIdField.value = GetLeadIDWithLeadQuery(WebService, XML);//Populate a string with an ID pulled from querying CRM Lead table. Using the XML Document details to peform a search in SQL
aLibr_LeadIdField.type = crmrecordtype.integer;
aLibr_LeadIdField.typeSpecified = true;

aNewLibraryRecord.records[0] = aFilePathField;
aNewLibraryRecord.records[1] = aFileNameField;
aNewLibraryRecord.records[2] = aLibr_LeadIdField;

libList[0] = aNewLibraryRecord;
addresult aResult = WebService.addrecord("library", libList);

Result of my code is that it creates a record ( as visible in the sql logs) - but does not add any of the fields in passing through.It only inserts the time created, time updated variables.

So big question:

How could I set up a way, using standard Sage CRM techniques to populate the library table with this information?

I would like to make a program that adds data into fields in my custom entity.

Thanks,

Matt

  • 0

    Before we get too far into diagnosing what's going on (and I suspect it's to to with your use of addrecord() as opposed to add()), is there a particular reason you're constructing the object rather than just using the typed library object? This is how I'd do the same thing, which absolutely does work:

    library aLibraryRecord = new library();

    aLibraryRecord.filepath = "test";

    aLibraryRecord.filename = getFileName();
    aLibraryRecord.leadid = 1;
    aLibraryRecord.leadidSpecified = true;

    addresult rez = ws.add("Library", new ewarebase[] { aLibraryRecord });

    Is the Library object not defined in your WSDL?

  • 0

    Hey Chris,

    That's right - the Library object its not defined in my WSDL. I cant create Library objects like that otherwise it would be awesome and I could create it as shown above.

    Therefore I have to use add record to create a Library rather than add.

    Is library meant to be defined in the WSDL ? It is a secondary entity for our sage system (2017 R2).

    Thanks,

    Matt

  • 0

    You can expose whatever you want to the web service.

    Go into SQL Server and issue the following update:

    UPDATE Custom_Tables SET bord_WebServiceTable = 'Y' WHERE Bord_Name = 'Library'

    Then either restart the CRM App Pool, or just restart IIS. Then update the web reference in your project and that should be it.

  • 0

    Thanks Chris -

    The record for Library was set to 'y'.

    Ran your statement anyways : performed the iis reset and low behold, after updating the web reference I can now use the library object :)

    Thanks for your reply - super helpful.

    I will post up my new code shortly

  • 0

    public void CreateNewLibraryRecord(WebService WebService) //Logging onto our web service previously

    {

    ewarebase[] CRMBase = new ewarebase[1];

    library newLibraryRecord = new library();//Generate new library object to populate and pass through to webservice/using add method

    #region Create from Library Record Fields

    newLibraryRecord.filename = getFileName();

    newLibraryRecord.filepath = getFilePath();

    newLibraryRecord.leadid = Convert.ToInt32((GetLeadIDWithLeadQuery(WebService)));

    newLibraryRecord.leadidSpecified = true;

    #endregion

    CRMBase[0] = newLibraryRecord;//Create our new library and populate the crm object for processing

    object result = WebService.add("Library", CRMBase);

    }