cancel
Showing results for 
Search instead for 
Did you mean: 

Export/import formatted search to XML

Former Member
0 Kudos

Hello, since I can export formatted search to XML and despues be able to import them. Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Nussi
Active Contributor
0 Kudos

Hi,

ater a look in the SDK DIAPI documentation:

use the FormattedSearches Object

with the Method GetAsXML

lg David

Former Member
0 Kudos

Later do I import it with the load as a common XML?

Answers (1)

Answers (1)

Former Member
0 Kudos

Later do I import it with the load as a common XML?

Nussi
Active Contributor
0 Kudos

Andres,

i recommend you the following:

first try to export a formatted search with

SaveXML method.

the result is a XML that you can than import with GetAsXML

try first SaveXML (i thought you've done that already), look how the XML looks

and than try to import the XML in another company.

thats how you do it with DIAPI.

lg David

Former Member
0 Kudos

Probably exporting this one badly to the XML. Serious how the code it to export to XML?. Thank you very much.

Nussi
Active Contributor

Hi Andreas,

i made a c# code for you

Export


string FileName = "C:\\TEST.xml";

SAPbobsCOM.FormattedSearches oFS = null;
oFS = ((SAPbobsCOM.FormattedSearches)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oFormattedSearches)));

oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode;

oFS.GetByKey(1); // IndexID from CSHS table
oFS.SaveXML(ref FileName);

Import


string FileName = "C:\\TEST.xml";

oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode;
oFS = ((SAPbobsCOM.FormattedSearches)(oCompany.GetBusinessObjectFromXML(FileName, 0)));
if (oFS.Add() == 0)
{
     Console.WriteLine("Added");
}
else
{
   Console.WriteLine(globals.oCompany.GetLastErrorDescription());
}

this code worked for me - but remember that formatted searches can only be assigned once to a field

actually i pray that you wanted this and not userqueries

lg David

Former Member
0 Kudos

Thank you very much, really itwas many usefulness your help. Regards.