I'm facing a strange Issue when I'm inserting or updating an item in SharePoint2019 list which contains a user column the save completes with no errors but the user column always have empty value,
below is my code
context.Load(context.Web, web => web.Lists);
await context.ExecuteQueryAsync();
List RiskList = context.Web.Lists.GetByTitle("Risks");
context.Load(RiskList);
context.Load(RiskList, r => r.Fields);
await context.ExecuteQueryAsync();
ListItem listItem = RiskList.GetItemById(projectRisks.Id);
List<ListItemFormUpdateValue> listItemFormUpdateValue = new List<ListItemFormUpdateValue>();
if (projectRisks.AssignedTo.HasValue)
{
listItem["AssignedTo"] = new FieldUserValue() { LookupId = projectRisks.AssignedTo.Value };
}
if (projectRisks.Owner.HasValue)
{
User OwnerUser = context.Web.SiteUsers.GetById(projectRisks.Owner.Value);
context.Load(OwnerUser);
await context.ExecuteQueryAsync();
listItem["Owner"] = new FieldUserValue() { LookupId = OwnerUser.Id };
}
listItemFormUpdateValue.Add(new ListItemFormUpdateValue() { FieldName = "Category", FieldValue = GetSPSelectedChoiceValue(context, RiskList, "Category", projectRisks.CategoryName).Result });
listItemFormUpdateValue.Add(new ListItemFormUpdateValue() { FieldName = "Status", FieldValue = GetSPSelectedChoiceValue(context, RiskList, "Status", projectRisks.StatusName).Result });
listItem["Contingency_x0020_plan"] = projectRisks.ContingencyPlan;
listItem["Cost"] = projectRisks.Cost;
listItem["Cost_x0020_Exposure"] = string.Empty;
listItem["Description"] = projectRisks.Description;
listItem["DueDate"] = projectRisks.DueDate;
listItem["Exposure"] = projectRisks.Exposure;
listItem["Impact"] = projectRisks.Impact;
listItem["Mitigation_x0020_plan"] = projectRisks.MitigationPlan;
listItem["Probability"] = projectRisks.Probability;
listItem["Title"] = projectRisks.Name;
listItem.ValidateUpdateListItem(listItemFormUpdateValue, false, string.Empty);
listItem.Update();
await context.ExecuteQueryAsync();
as you can see in the AssignTo and in Owner Columns no mater how I try to save the users values the list will take the default value which is null.
I have made sure that there is values in the assigned to and Owner properties and I have tried using the ListItemFormUpdateValue but with no luck.
Thanks in advance
Related
I am using GraphAPI SDK to create a new Team in Microsoft Teams:
var newTeam = new Team()
{
DisplayName = teamName,
Description = teamName,
AdditionalData = new Dictionary<string, object>()
{
{"template#odata.bind", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}
},
Members = new TeamMembersCollectionPage()
{
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{"user#odata.bind", $"https://graph.microsoft.com/v1.0/users/{userId}"}
}
}
}
};
var team = await this.graphStableClient.Teams
.Request()
.AddAsync(newTeam);
The problem is that I get always null. According documentation this method returns a 202 response (teamsAsyncOperation), but the AddAsync method from SDK returns a Team object. Is there any way to get the tracking url to check if the team creation has been finished with the SDK?
Documentation and working SDK works different... As they wrote in microsoft-graph-docs/issues/10840, we can only get the teamsAsyncOperation header values if we use HttpRequestMessage as in contoso-airlines-teams-sample. They wrote to the people who asks this problem, look to the joined teams :)) :)
var newTeam = new Team()
{
DisplayName = model.DisplayName,
Description = model.Description,
AdditionalData = new Dictionary<string, object>
{
["template#odata.bind"] = $"{graph.BaseUrl}/teamsTemplates('standard')",
["members"] = owners.ToArray()
}
};
// we cannot use 'await client.Teams.Request().AddAsync(newTeam)'
// as we do NOT get the team ID back (object is always null) :(
BaseRequest request = (BaseRequest)graph.Teams.Request();
request.ContentType = "application/json";
request.Method = "POST";
string location;
using (HttpResponseMessage response = await request.SendRequestAsync(newTeam, CancellationToken.None))
location = response.Headers.Location.ToString();
// looks like: /teams('7070b1fd-1f14-4a06-8617-254724d63cde')/operations('c7c34e52-7ebf-4038-b306-f5af2d9891ac')
// but is documented as: /teams/7070b1fd-1f14-4a06-8617-254724d63cde/operations/c7c34e52-7ebf-4038-b306-f5af2d9891ac
// -> this split supports both of them
string[] locationParts = location.Split(new[] { '\'', '/', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
string teamId = locationParts[1];
string operationId = locationParts[3];
// before querying the first time we must wait some secs, else we get a 404
int delayInMilliseconds = 5_000;
while (true)
{
await Task.Delay(delayInMilliseconds);
// lets see how far the teams creation process is
TeamsAsyncOperation operation = await graph.Teams[teamId].Operations[operationId].Request().GetAsync();
if (operation.Status == TeamsAsyncOperationStatus.Succeeded)
break;
if (operation.Status == TeamsAsyncOperationStatus.Failed)
throw new Exception($"Failed to create team '{newTeam.DisplayName}': {operation.Error.Message} ({operation.Error.Code})");
// according to the docs, we should wait > 30 secs between calls
// https://learn.microsoft.com/en-us/graph/api/resources/teamsasyncoperation?view=graph-rest-1.0
delayInMilliseconds = 30_000;
}
// finally, do something with your team...
I found a solution from another question... Tried and saw that it's working...
I have a TreeTable which shows data from oData service. Some of the data fields contains symbols of slash ("/", f.e. cats/dogs). My service understands them like a new kind of parameter and doesn't display them in a TreeTable (gives a blank row).
Here is my code:
oData = new sap.ui.model.odata.ODataModel(".../categories/categories.xsodata/", false);
oData.read("/Categories/",
null,
null,
false,
function(oData, oResponse){
flat = {};
for (var i = 0; i < oData.results.length; ++i) {
var item, group, type, code;
var getSubNode = function(obj, key) {
if (!obj[key]) {
obj[key] = {'NAME': key}
}
return obj[key];
};
item = oData.results[i];
group = getSubNode(flat, item.PET_GROUP);
type = getSubNode(group, item.PET_TYPE);
item.NAME = item.GENDER;
item.__metadata = "";
type[item.GENDER] = item;
}
data = {flat : flat,};
});
ojModel = new sap.ui.model.json.JSONModel();
ojModel.setData(data);
oTable.setModel(ojModel);
oTable.bindRows("/flat");
return oTable;
Maybe there is a solution for this?
I have a requirement to add pre-payment to a sales order. Accounting has setup the required classes and payment methods in Acumatica. I am able to do this through the GUI, but when I try to enter the payment information on the sales order using the Web Service, I get an error response back. The error response is: PX.Data.PXException: Error #14: Inserting 'SOAdjust' record raised one or more errors. Please review. Error: 'Reference Nbr.' may not be empty.
` SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
List<Command> cmds = new List<Command>();
cmds.AddRange(new Command[]{
new Value {Value = "C3", LinkedCommand = SO301000.OrderSummary.OrderType},
new Value { Value = orderNbr, LinkedCommand = SO301000.OrderSummary.OrderNbr, Commit = true},
SO301000.Payments.ServiceCommands.NewRow,
new Value { Value = "Prepayment", LinkedCommand = SO301000.Payments.DocType},
new Value { Value = paymentNbr, LinkedCommand = SO301000.Payments.ReferenceNbr, Commit = true },
// new Value { Value = "3.00" , LinkedCommand = SO301000.Payments.AppliedToOrder, Commit = true},
SO301000.Actions.Save,
SO301000.OrderSummary.OrderNbr
});
string orderNumber = string.Empty;
try
{
var SO301000ContentReturned = context.SO301000Submit(cmds.ToArray());
orderNumber = SO301000ContentReturned[0].OrderSummary.OrderNbr.Value;
Console.WriteLine(orderNumber);
}
catch (Exception exception)
{
orderNumber = exception.Message;
Console.WriteLine(exception);
}
return orderNumber;`
Any suggestions? I have tried using the AR302000 screen as well to apply the payment to the order from the payment screen and received the same error message.
There is a known limitation in grids that are driven by two key fields (in this case: DocType+ReferenceNbr). In this scenario, only the 2nd key should have Commit=true set, so you need to set Commit=false on the DocType field. But instead of doing it from the Value object, you need to do it on the schema content object.
The other Commit=true and the NewRow command are unnecessary. I've edited your original code below, this is how it should look:
SO301000.Payments.DocType.Commit = false; //This is the line that I added
List<Command> cmds = new List<Command>();
cmds.AddRange(new Command[]{
new Value {Value = "C3", LinkedCommand = SO301000.OrderSummary.OrderType},
new Value { Value = orderNbr, LinkedCommand = SO301000.OrderSummary.OrderNbr},
new Value { Value = "Prepayment", LinkedCommand = SO301000.Payments.DocType},
new Value { Value = paymentNbr, LinkedCommand = SO301000.Payments.ReferenceNbr},
//new Value { Value = "3.00" , LinkedCommand = SO301000.Payments.AppliedToOrder},
SO301000.Actions.Save,
SO301000.OrderSummary.OrderNbr
});
string orderNumber = string.Empty;
try
{
var SO301000ContentReturned = context.SO301000Submit(cmds.ToArray());
orderNumber = SO301000ContentReturned[0].OrderSummary.OrderNbr.Value;
Console.WriteLine(orderNumber);
}
catch (Exception exception)
{
orderNumber = exception.Message;
Console.WriteLine(exception);
}
return orderNumber;
I have requirement to retrive Item information for multiple Ids, I am using ItemQuery for the same using below code,but its gives error as "{"Invalid or missing value of the choice identifier 'ItemsElementName' of type 'Intuit.Ipp.Data.Qbd.ItemsChoiceType4[]'."}".
Please suggest if anyone is having any idea about how to use ListIdSet for ItemQuery .
List<Intuit.Ipp.Data.Qbd.IdType> ids = new List<Intuit.Ipp.Data.Qbd.IdType>();
ids.Add(new Intuit.Ipp.Data.Qbd.IdType() { Value = "123460", idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG });
ids.Add(new Intuit.Ipp.Data.Qbd.IdType() { Value = "789100", idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG });
ids.Add(new Intuit.Ipp.Data.Qbd.IdType() { Value = "111213", idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG });
Intuit.Ipp.Data.Qbd.ItemQuery qbdQuery = new Intuit.Ipp.Data.Qbd.ItemQuery();
List<Intuit.Ipp.Data.Qbd.Item> itemQueryResult = null;
qbdQuery.Items = ids.ToArray();
qbdQuery.ItemsElementName = new ItemsChoiceType4[] { ItemsChoiceType4.ListIdSet};
itemQueryResult = qbdQuery.ExecuteQuery<Intuit.Ipp.Data.Qbd.Item>(context).ToList<Intuit.Ipp.Data.Qbd.Item>();
Regards,
Reshma D.
Here is an example
ItemQuery qbdItemQuery = new ItemQuery();
qbdItemQuery.Items = new object[] { new IdSet() { Id = new IdType[] { new IdType() { idDomain = idDomainEnum.NG, Value = "79841" } } } };
qbdItemQuery.ItemsElementName = new ItemsChoiceType4[] { ItemsChoiceType4.ListIdSet };
List<Item> ItemQueryResult = qbdItemQuery.ExecuteQuery<Item>(context).ToList<Item>();
The code seems to run. I don't get any error messages, but an invoice does not appear in QB after I sync. The code is basically this (http://pastebin.com/y7QENxeX) with a few (presumably) minor changes as noted. I'm able to create Accounts and Customers so I believe the basic infrastructure of my app is good. I don't understand why I'm stuck on invoices. I think my customerID is 2. I only have 5 in my company right now. And I think my itemID is 1 as I only have one in QB right now.
Any and all help is greatly appreciated.
Intuit.Ipp.Data.Qbd.PhysicalAddress physicalAddress = new Intuit.Ipp.Data.Qbd.PhysicalAddress();
physicalAddress.Line1 = "123 Main St.";
physicalAddress.Line2 = "Apt. 12";
physicalAddress.City = "Mountain View";
physicalAddress.CountrySubDivisionCode = "CA";
physicalAddress.Country = "USA";
physicalAddress.PostalCode = "94043";
physicalAddress.Tag = new string[] { "Billing" };
Intuit.Ipp.Data.Qbd.InvoiceHeader invoiceHeader = new Intuit.Ipp.Data.Qbd.InvoiceHeader();
invoiceHeader.ARAccountId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "37" };
invoiceHeader.ARAccountName = "Accounts Receivable";
// original code : invoiceHeader.CustomerId = new IdType() { idDomain = idDomainEnum.NG, Value = "3291253" };
invoiceHeader.CustomerId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "2" };
invoiceHeader.Balance = (decimal)100.00;
invoiceHeader.BillAddr = physicalAddress;
invoiceHeader.BillEmail = "detroit#tigers.com";
invoiceHeader.CustomerName = "Detroit Tigers";
invoiceHeader.DocNumber = "1234567";
invoiceHeader.DueDate = DateTime.Now;
invoiceHeader.ShipAddr = physicalAddress;
invoiceHeader.ShipDate = DateTime.Now;
invoiceHeader.TaxAmt = (decimal)5;
invoiceHeader.TaxRate = (decimal).05;
invoiceHeader.ToBeEmailed = false;
invoiceHeader.TotalAmt = (decimal)105.00;
List<Intuit.Ipp.Data.Qbd.InvoiceLine> listLine = new List<Intuit.Ipp.Data.Qbd.InvoiceLine>();
//Loop for multiple invoice lines could be added here
Intuit.Ipp.Data.Qbd.ItemsChoiceType2[] invoiceItemAttributes = { Intuit.Ipp.Data.Qbd.ItemsChoiceType2.ItemId, Intuit.Ipp.Data.Qbd.ItemsChoiceType2.UnitPrice, Intuit.Ipp.Data.Qbd.ItemsChoiceType2.Qty };
// original code : object[] invoiceItemValues = { new IdType() { idDomain = idDomainEnum.QB, Value = "5" }, new decimal(33), new decimal(2) };
object[] invoiceItemValues = { new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "1" }, new decimal(33), new decimal(2) };
var invoiceLine = new Intuit.Ipp.Data.Qbd.InvoiceLine();
invoiceLine.Amount = 66;
invoiceLine.AmountSpecified = true;
invoiceLine.Desc = "test " + DateTime.Now.ToShortDateString();
invoiceLine.ItemsElementName = invoiceItemAttributes;
invoiceLine.Items = invoiceItemValues;
invoiceLine.ServiceDate = DateTime.Now;
invoiceLine.ServiceDateSpecified = true;
listLine.Add(invoiceLine);
Intuit.Ipp.Data.Qbd.Invoice invoice = new Intuit.Ipp.Data.Qbd.Invoice();
invoice.Header = invoiceHeader;
invoice.Line = listLine.ToArray();
Intuit.Ipp.Data.Qbd.Invoice addedInvoice = commonService.Add(invoice);
Chris
You need to read the following information about how QuickBooks for Windows Sync Manager works, how to see if Sync ran correctly, if objects are in an errored state and how to resolve. It could be any number of things. Once a record is inserted into the cloud, it asynchronously downloads to QuickBooks on the desktop, at which time business logic is applied and records are matched from the cloud to the desktop. If there is an issue, sync manager will show a record of the object that failed, why it failed and the object will now be in an error state.
At this point you can review the error and take steps to fix, like revert or update and resubmit. Links to the documentation below.
QuickBooks Sync Manager
Data Sync
Objects in Errored State
Sync Activity
Sync Status
regards
Jarred