I want to retrieve vendorBills from Netsuite.
Here is my code
TransactionSearch transactionSearch = new TransactionSearch();
TransactionSearchBasic tranSearchBasic = new TransactionSearchBasic();
TransactionSearchAdvanced tranAdvancedSearch = new TransactionSearchAdvanced();
SearchDateField searchDate = new SearchDateField();
searchDate.setOperator(SearchDateFieldOperator.within);
searchDate.setSearchValue(startDate);
searchDate.setSearchValue2(endDate);
tranSearchBasic.setDateCreated(searchDate);
transactionSearch.setBasic(tranSearchBasic);
tranAdvancedSearch.setCriteria(transactionSearch);
SearchResult billResult = port.search(tranAdvancedSearch);
The above code retruns all Transaction records created between specified date.
But I want to filter out only vendorBill.
I have tried the following
String[] type = new String[1];
type[0]=RecordType._vendorBill;
tranSearchBasic.setType(type);
but it returns null.
webservice host address:https://webservices.na1.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl
any immediate help is appreciated
$typeSearchField = new SearchStringField();
$typeSearchField->operator = SearchStringFieldOperator::is;
$typeSearchField->searchValue = "SalesOrder";
$search = new TransactionSearchBasic();
$search->recordType = $typeSearchField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
This is how you would go about doing this in PHP for Sales Orders. Code for C# should be something like the following.
TransactionSearchBasic tranSearchBasic = new TransactionSearchBasic();
SearchDateField searchDate = new SearchDateField();
searchDate.setOperator(SearchDateFieldOperator.within);
searchDate.setSearchValue(startDate);
searchDate.setSearchValue2(endDate);
SearchStringField searchRecordType = new SearchStringField();
searchRecordType.setOperator(SearchStringFieldOperator.is);
searchRecordType.setSearchValue("VendorBill");
tranSearchBasic.setDateCreated(searchDate);
tranSearchBasic.setRecordType(searchRecordType);
SearchResult billResult = port.search(tranSearchBasic);
Related
I have an Excel file with one sheet and one chart. I am trying to copy this chart and paste it on a new Word document using OpenXml SDK. I do not want an image of the chart, but an editable chart object, not referenced to the Excel file.
This is what I tried:
using (SpreadsheetDocument document = SpreadsheetDocument.Open("Test1.xlsx", true))
{
var bkPart = document.WorkbookPart;
var workbook = bkPart.Workbook;
var s = workbook.Sheets.FirstOrDefault();
var wsPart = bkPart.WorksheetParts.FirstOrDefault();
var dp = wsPart.DrawingsPart;
var dWs = dp.WorksheetDrawing;
var cp = dp.ChartParts.FirstOrDefault();
var plotArea = cp.ChartSpace.Descendants<PlotArea>().FirstOrDefault();
using (var docx = WordprocessingDocument.Open("Test1.docx", true))
{
docx.MainDocumentPart.Document.Body.RemoveAllChildren();
var cpw = docx.MainDocumentPart.AddPart(cp);
var p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();
var r = new Run();
var d = new Drawing();
var i = new Inline();
var g = new Graphic();
var gd = new GraphicData();
var c = new DocumentFormat.OpenXml.Drawing.Charts.Chart();
docx.MainDocumentPart.Document.Body.Append(p);
p.Append(r);
r.Append(d);
d.Append(i);
i.Append(g);
g.Append(gd);
gd.Append(c);
// I am stuck here
}
}
I tried to take the ChartPart from Excel and adding it to the Word document and then to create a new chart referencing the inserted new ChartPart. Unfortunately, I am stuck on this step. How can I get and use this reference to create the chart? Otherwise is there another way to copy a chart from Excel to Word?
Thanks in advance.
I found this workaround to copy a chart from Excel to Word:
Create a new ChartPart on the Word document.
Add to this ChartPart a ChartSpace cloned from Excel.
Add a new chart to the Word document referencing the new ChartPart.
This is the code:
using (SpreadsheetDocument document = SpreadsheetDocument.Open("Test1.xlsx", true))
{
var bkPart = document.WorkbookPart;
var workbook = bkPart.Workbook;
var s = workbook.Sheets.FirstOrDefault();
var wsPart = bkPart.WorksheetParts.FirstOrDefault();
var dp = wsPart.DrawingsPart;
var dWs = dp.WorksheetDrawing;
var cp = dp.ChartParts.FirstOrDefault();
using (var docx = WordprocessingDocument.Open("Test1.docx", true))
{
MainDocumentPart mainPart = docx.MainDocumentPart;
ChartPart chartPart = mainPart.AddNewPart<ChartPart>("rId777");
chartPart.ChartSpace = (ChartSpace)cp.ChartSpace.Clone();
var paragraph = new DocumentFormat.OpenXml.Wordprocessing.Paragraph() { RsidParagraphAddition = "00C75AEB", RsidRunAdditionDefault = "000F3EFF" };
Run run = new Run();
Drawing drawing = new Drawing();
Inline inline = new Inline();
inline.Append(new Extent() { Cx = 5274310L, Cy = 3076575L });
DocProperties docPros = new DocProperties() { Id = (UInt32Value)1U, Name = "Chart7" };
inline.Append(docPros);
Graphic g = new Graphic();
var graphicData = new GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart" };
var chartReference = new ChartReference() { Id = "rId777" };
graphicData.Append(chartReference);
g.Append(graphicData);
inline.Append(g);
drawing.Append(inline);
run.Append(drawing);
paragraph.Append(run);
mainPart.Document.Body.Append(paragraph);
}
}
I am working on SharePoint 2016 CSOM to get list item version history. unfortunately i am not getting the field values. please find the code below.
var file = item.File;
var versionFiles = file.Versions;
var fa = file.ListItemAllFields;
clientContext.Load(fa);
clientContext.Load(file);
clientContext.Load(versionFiles);
clientContext.ExecuteQuery();
if (null != versionFiles)
{
var fileVersion = file.Versions[5];
SP.File oldFile =web.GetFileByServerRelativeUrl("/sites/site/_vti_history/1234/list1/file1.pdf");
var allField = oldFile.ListItemAllFields;
clientContext.Load(allField);
}
You could get version history metadata from Lists.asmx.
Sample code:
var web = clientContext.Web;
List spList = clientContext.Web.Lists.GetByTitle("MyDoc");
var item = spList.GetItemById(43);
clientContext.Load(spList);
clientContext.Load(item);
clientContext.ExecuteQuery();
#region customList
Lists.Lists listService = new Lists.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.Url = siteUrl + "/_vti_bin/lists.asmx";
XmlNode nodeAttachments = listService.GetVersionCollection(spList.Id.ToString(), item.Id.ToString(), "Title");
foreach (System.Xml.XmlNode xNode in nodeAttachments)
{
Console.WriteLine(xNode.Attributes["Title"].Value);
}
How to Create Custom Record in netsuite through Suitetalk in C#?
CustomRecord rec = new CustomRecord();
RecordRef recType = new RecordRef();
recType.internalId = "10"; // Internal ID of custom record type, not individual record id
recType.type = RecordType.customRecord;
recType.typeSpecified = true;
rec.recType = recType;
rec.name = "My new custom record";
CustomFieldRef[] customFieldArray = new CustomFieldRef[1];
StringCustomFieldRef stringField = new StringCustomFieldRef();
stringField.scriptId = "custrecord_string";
stringField.value = "A string";
customFieldArray[0] = stringField;
rec.customFieldList = customFieldArray;
WriteResponse response = _service.add(rec);
I'm using C# and CSOM to build an application that creates an event in a SharePoint calendar that I know exists in my O365 subscription. I know O365 is SharePoint 2013, but my application targets SharePoint 2010, so I'm going to have to deal with both versions.
No exceptions are thrown and everything appears to succeed, but the new event does not display in the calendar, even after a page refresh. If I get a collection of items with the same event title, the program-entered event is returned, and appears to contain all the columns set in code.
The CalendarItemCreate function puts data in all the required columns of the calendar. If I search for other calendar items I have hand-entered through the SharePoint calendar, I find them. The only difference I can see between either hand-entered or program-entered events is the "Description" column has ' for the hand-entered events.
Any ideas?
private void CalendarItemCreate(ICalendarItem item) {
using (var context = new ClientContext(_calendarLocation)) {
context.Credentials = _credentials;
var web = context.Web;
var transferScheduleList = web.Lists.GetByTitle(TransferScheduleToken);
var listItemCreationInformation = new ListItemCreationInformation();
var listItem = transferScheduleList.AddItem(listItemCreationInformation);
listItem[TitleToken] = item.EventTitle;
listItem[EventDateToken] = item.EventStartLocal;
listItem[EndDateToken] = item.EventStartLocal.AddMinutes(30);
listItem[DescriptionToken] = string.Empty; //item.EventDescription;
listItem[TransferTypeToken] = item.EventTransferType;
listItem[TransferStatusToken] = item.EventTransferStatus;
listItem[CategoryToken] = "Data Transfer";
listItem[ConfigurationFileLocationToken] = item.ConfigurationFileLocation;
listItem[EventTypeToken] = 0;
listItem[FallDayEventToken] = false;
listItem[FrecurrenceToken] = false;
listItem.Update();
context.ExecuteQuery();
}
The solution was a combination of formatting the dates as strings that SharePoint could understand and data type mismatches in two of my transfer columns. The code below was successful.
using (var context = new ClientContext(_calendarLocation)) {
context.Credentials = _credentials;
var web = context.Web;
var transferScheduleList = web.Lists.GetByTitle(TransferScheduleToken);
var listItemCreationInformation = new ListItemCreationInformation();
var listItem = transferScheduleList.AddItem(listItemCreationInformation);
listItem[TitleToken] = item.EventTitle;
listItem[EventDateToken] = item.EventStartLocal.ToUniversalTime().ToString(#"yyyy-MM-ddTHH:mm:ssZ");
listItem[EndDateToken] = item.EventStartLocal.AddMinutes(30).ToUniversalTime().ToString(#"yyyy-MM-ddTHH:mm:ssZ");
listItem[DescriptionToken] = item.EventDescription;
listItem[TransferTypeToken] = item.EventTransferType.ToString();
listItem[TransferStatusToken] = item.EventTransferStatus.ToString();
listItem[CategoryToken] = "Data Transfer";
listItem[ConfigurationFileLocationToken] = item.ConfigurationFileLocation;
listItem[EventTypeToken] = 0;
listItem[FallDayEventToken] = false;
listItem[FrecurrenceToken] = false;
listItem.Update();
context.ExecuteQuery();
Does anyone know how to read the number of attachments, and the names etc for a ListItem using the Client .Net Object model in SharePoint?
Thanks
// For getting the list item field information
public void LoadPropertyInfo()
{
using (context = new ClientContext(siteCollectionUrl))
{
spWeb = context.Web;
propertiesList = spWeb.Lists.GetByTitle(listName);
FieldCollection fields = propertiesList.Fields;
context.Load(fields);
SP.CamlQuery query = new SP.CamlQuery();
query.ViewXml = string.Format("<View><Query><Where><Eq><FieldRef Name=\"{0}\" /><Value Type=\"Text\">{1}</Value></Eq></Where></Query></View>", propertyID, PropertyIDValue);
listItems = propertiesList.GetItems(query);
context.Load(listItems);
context.ExecuteQueryAsync(GetRequestSucceeded, RequestFailed);
}
}
// Pass the item id here for getting the attachments
private void GetAttchmentCollection(string id)
{
string RedirectHost = string.Empty;
string Host = string.Empty;
context = SP.ClientContext.Current;
RedirectHost = serviceUrl + "_vti_bin/Lists.asmx";
BasicHttpBinding binding = new BasicHttpBinding();
if (System.Windows.Browser.HtmlPage.Document.DocumentUri.Scheme.StartsWith("https"))
{
binding.Security.Mode = BasicHttpSecurityMode.Transport;
}
binding.MaxReceivedMessageSize = int.MaxValue;
EndpointAddress endpoint = new EndpointAddress(RedirectHost);
ServiceReference1.ListsSoapClient oClient = new ServiceReference1.ListsSoapClient(binding, endpoint);
oClient.GetAttachmentCollectionCompleted += new EventHandler<ServiceReference1.GetAttachmentCollectionCompletedEventArgs>(oClient_GetAttachmentCollectionCompleted);
oClient.GetAttachmentCollectionAsync(listName, id);
}
Your can try this link too.
http://helpmetocode.blogspot.com/2011/11/managed-client-object-models-in.html