Getting "Editor" field value throws the value range exception under a non-System account - sharepoint-2010

Below's the piece of legacy code of migration from 2007 to 2010. It gets the values of the author and the editor fields. The values are the same user, actually. When I login under the SPAdmin rights, both fields work okay. However, under a test account, the attempt to get the value of the Editor field fails with the following exception: "Value does not fall within the expected range", while the Author field still works fine. Let's see the code:
SPQuery sPQuery = new SPQuery();
sPQuery.Query = queryString;
sPQuery.ExpandRecurrence = true;
sPQuery.CalendarDate = startDateTime;
sPQuery.DatesInUtc = false;
SPListItemCollection items = list.GetItems(sPQuery);
SPListItem item = items[0];
object author = item["Author"]; //works always, under any account
object editor = item["Editor"]; // **doesn't work under non-system account**
Well, here is the line of code that always works for the Editor too:
object editor = item.ParentList.GetItemById(item.ID)["Editor"];
So I wonder what wrong with that and what should I check.
Thanks.

Well, the problem was in the the lookup threshold limitation.

Related

Print SSRSReport to file (.PDF)

I need to find a way to "print" a SrsReport, in my case SalesInvoice, as .PDF (or any kind of file) to a specific location.
For this I modified the SRSPrintDestinationSettings to output the SalesInvoice-Report as a .PDF:
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(#'\\AXDEV\Bottomline\Test\test.pdf');
Somehow this gets ignored and I recive a Email with the report as .PDF attached.
For example this will run on ax 2012 but won't print to PDF for me.
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour;
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract rdpContract = new PurchPurchaseOrderContract();
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
select firstOnly1 * from custInvoiceJour where custInvoiceJour.SalesId != "";
// Define report and report design to use
controller.parmReportName(ssrsReportStr(SalesInvoice,Report));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
rdpContract.parmRecordId(custInvoiceJour.RecId);
controller.parmReportContract().parmRdpContract(rdpContract);
// Explicitly provide all required parameters
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(#'\\AXDEV\Bottomline\Test\test.pdf');
//tokens = settings as SrsPrintDestinationTokens();
//controller.parmPrintDestinationTokens(null);
//Suppress report dialog
controller.parmShowDialog(false);
// Execute the report
controller.startOperation();
Questions:
Is this the correct way to print a srsReport to .pdf?
Am I passing/setting the printerSettings correctly?
Where does it say "Send Email"?
EDIT: Code is working fine. We are using external code of a company which simply doesnt implement this.
Use the cleaner code of Alex Kwitny
Here is working code for me. I just quickly coded this from scratch/memory based off of glancing at yours, so compare for differences.
I have two things marked (1) and (2) for you to try with your code, or just copy/paste mine.
static void JobSendToPDFInvoice(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings settings;
CustInvoiceJour custInvoiceJour = CustInvoiceJour::findRecId(5637925275);
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
Args args = new Args();
controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
controller.parmShowDialog(false);
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmDocumentTitle(CustInvoiceJour.InvoiceId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
// (1) Try by passing args
args.record(custInvoiceJour);
args.parmEnum(PrintCopyOriginal::Original);
args.parmEnumType(enumNum(PrintCopyOriginal));
controller.parmReportContract().parmRdpContract(salesInvoiceContract);
controller.parmArgs(args);
// (2) Try explicitly preventing loading from last value
// controller.parmLoadFromSysLastValue(false);
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(#'C:\Temp\Invoice.pdf');
controller.startOperation();
}
Since you are talking about the sales invoice the report is using the print management feature and you cannot simply override the print settings like that.
You need to override the runPrintMgmt on the controller class and determine there whether you want default print management or your own code.
See this post for an example: http://www.winfosoft.com/blog/microsoft-dynamics-ax/manipulating-printer-settings-with-x

Using Visual Studios 2013 and VB.net, how to capitalize lets in a textfield mixed with numbers

I am and entry level programmer and i have a task that is asking me to modify a page that takes and entry from a textfield that is mixed with letters and numbers. this field is called a "job#" and then the page will search a database for that in particular job. problem is that it only searches it if its in capital letters. need to have it accept caps and lower case letters. it is in VB.net. and i went to the controller and i have this code here
Try
res.success = True
res.message = ""
Dim r = New Objects.Business.Capital.CapitalRequest(jobNumber)
Dim req = New ViewModels.Business.Capital.CapitalRequest(r)
Models.Core.Approvals.AddIApprovableToCache(r)
res.data = req
Return New PCA.Core.Web.JSON.JSONPResult() With { _
.Data = res,
.Callback = callback
}
i tried to tack on "ToUpper() after the (jobnumber) because i thought that is where it takes the number entered and applies it to a variable to search the database for it. but it says that 'ToUpper()' is not a member of 'Trident.Objects.Business.Capital.CapitalRequest' im assuming the parent class doesnt have the package where ToUpper() is ?
i tried to tack on "ToUpper() after the (jobnumber) because i thought
that is where it takes the number entered and applies it to a variable
to search the database for it. but it says that 'ToUpper()' is not a
member of 'Trident.Objects.Business.Capital.CapitalRequest'
Instead of
Dim r = New Objects.Business.Capital.CapitalRequest(jobNumber).ToUpper()
use
Dim r = New Objects.Business.Capital.CapitalRequest(jobNumber.ToUpper())

What is the merchant id?

I'm having issues getting paypal integrated into my windows 8 app. I'm not sure what the "merchantId" is suppose to be, I'm assuming the terminology doesn't line up with what is on the developer portal?
In this code sample, Execute() returns false without showing any prompt:
BuyNow buyNow = new BuyNow([I've tried several ids I found from the portal])
{
UseSandbox = true,
};
ItemBuilder itemBuilder = new ItemBuilder(this.product.Name);
itemBuilder.Description(this.product.Description);
itemBuilder.Name(this.product.Name);
itemBuilder.Price((product.SalePrice ?? product.Price).ToString());
itemBuilder.Quantity(1);
itemBuilder.ID (this.product.Id.ToString());
Item item = itemBuilder.Build();
buyNow.AddItem(item);
bool buyNowResult = await buyNow.Execute();
Alright, for the next person. The 'MerchantId' refers to 'Merchant account ID' which is found on the www.sandbox.paypal.com site under Profile -> My Business Info.
I was also having issues because the string I was entering for the description was too long. Be sure to hook up to the error event to get a meaningful error message. The BuyNow object isn't populated with the error message despite it having an Error property.
buyNow.Error += (sender, e) =>
{
// e has the error
};

RavenDB assigning already used Id to Document

I have an excel file that contains a list of UserAccounts. I also havea method to import those UserAccounts and save them into RavenDB. In the excel file I store the Id of the UserAccount Object (useraccounts/55). RavenDB is not assigning the value, I am assigning it. My import is working great.
However,
Later on, I try to save a new UserAccount through the admin panel using the following method:
[HttpPost]
public ActionResult Create(UserAccountViewModel input)
{
// Validation omitted
var model = new UserAccount()
{
Email = input.Email,
FirstName = input.FirstName,
LastName = input.LastName,
Phone = input.Phone,
Username = input.Username,
AuthorizeNetCustomerProfileId = customer.ProfileID,
Password = input.Password,
};
Raven.Store(model);
Raven.SaveChanges();
return RedirectToAction("Index");
}
When I call
Raven.Store(model)
It assigns an Id to the new UserAccount object but it starts at 1. So the first time I try to do this it assigns UserAccounts/1 to my new UserAccount. The issue is that UserAccounts/1 already exists from my import so when I call save changes I am getting an etag exception.
When I run the method again it assigns UserAccounts/2 and so on? Ideas?
The easiest way would be to have a string Id property in your UserAccount class, and assign it a value of "UserAccounts/". That trailing slash is going to ask RavenDB to assign it an ID using an identity-like process, instead of HiLo. Its somewhat slower, but it'll work.
The better way of solving this is by changing the HiLo documents on the server, making them start with the first available range, but thats messier.

Creating new smartform data using Ektron ContentTypes

Ektron 8.0.1 SP1
I am using SmartForms and Content Types to read (and hopefully write) data. I can read data but now I am attempting to write a new record similar to the following.
ContentTypeManager<member> contentTypeManager = new ContentTypeManager<member>();
ContentType<member> newmem = new ContentType<member>();
newmem.SmartForm.details.field1 = "Chuck"; // This line throws 'Object reference not set to an instance of an object.' error
newmem.SmartForm.details.field2 = "Norris";
contentTypeManager.Update(newmem);
I get the error "Object reference not set to an instance of an object." for that first assignment line. What am I missing?
I am having trouble finding good documentation on ContentTypes for 8.0.1 now that the Ektron website has been redesigned.
Thx.
Thanks for clarifying, to ADD content to a folder that has a smartform assigned to it, the basic code block should get you started: (Note: the Html attribute of the content is simply the xml matched to the schema you created)
Ektron.Cms.Framework.Content.ContentManager cmanager = new Cms.Framework.Content.ContentManager();
Ektron.Cms.ContentData cdata = new ContentData();
cdata.FolderId = 0;
cdata.XmlConfiguration.Id = 0; //SMARTFORM ID HERE
cdata.Html = "<root><field1>field1 value</field1><field2>field2 value</field2></root>";
cmanager.Add(cdata);
You could update ContentTypes.cs to include an Add method. Just copy the Update method and change contentManager.Update to contentManager.Add.
public void Add(ContentType<T> contentType)
{
Initialize();
contentType.Content.Html = Ektron.Cms.EkXml.Serialize(typeof(T), contentType.SmartForm);
contentManager.Add(contentType.Content);
}
Unfortunately, contentManager.Add returns void. Ideally it should return the new content ID.