Microsoft Azure > Azure Active Directory - azure-ad-b2c

I created an extension :
SchemaExtension objExtDef = new SchemaExtension()
{
Description = "Extention to Store User Dates",
Id = "UserDates",
Properties = new List<ExtensionSchemaProperty>()
{
new ExtensionSchemaProperty() { Name = "CreateDate", Type = "DateTime" },
new ExtensionSchemaProperty() { Name = "PasswordChangeDate", Type = "DateTime" }
},
TargetTypes = new List<string>()
{
"User"
}
};
SchemaExtension schemaExtension = Task.Run(() => graphserviceClient.SchemaExtensions.Request().AddAsync(objExtDef)).Result;
Made it Available :
var schemaExtension = new SchemaExtension
{
Status = "Available",
};
var result = Task.Run(() => graphserviceClient.SchemaExtensions["extuce7u7qp_UserDates"].Request().UpdateAsync(schemaExtension)).Result;
Searched and confirmed that it is created and available :
var lstAllExtensions = Task.Run(() => graphserviceClient.SchemaExtensions.Request().Filter("id%20eq%20'extuce7u7qp_UserDates'").GetAsync()).Result;
Trying to add user along with additional data in that extension :
UserDatesExtension objUserDatesExtension = new UserDatesExtension();
objUserDatesExtension.CreateDate = DateTime.Today;
objUserDatesExtension.PasswordChangeDate = DateTime.Today;
dctExtensions.Add("extuce7u7qp_UserDates", objUserDatesExtension);
Microsoft.Graph.User objNewUser = new Microsoft.Graph.User
{
AccountEnabled = true,
DisplayName = string.Format("{0} {1}", objUser.FirstName, objUser.LastName),
MailNickname = "TestUC",
PasswordProfile = new PasswordProfile
{
Password = "testpass",
ForceChangePasswordNextSignIn = false
},
UserPrincipalName = string.Format("{0}#test.onmicrosoft.com", objUser.UserIdentity),
GivenName = objUser.FirstName,
Surname = objUser.LastName,
City = objUser.Address != null ? objUser.Address.City : null,
Country = objUser.Address != null ? objUser.Address.Country : null,
State = objUser.Address != null ? objUser.Address.Region : null,
MobilePhone = !string.IsNullOrEmpty(objUser.Phone) ? objUser.Phone : null,
PreferredLanguage = objUser.PreferredLanguage,
AdditionalData = dctExtensions
};
Microsoft.Graph.User objCreatedUser = Task.Run(() => graphserviceClient.Users.Request().AddAsync(objNewUser)).Result;
That is throwing exception that the extension ID is not valid.
This was working earlier.
UserDatesExtension Class, used above :
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class UserDatesExtension
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "CreateDate", Required = Newtonsoft.Json.Required.Default)]
public DateTime CreateDate { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "PasswordChangeDate", Required = Newtonsoft.Json.Required.Default)]
public DateTime PasswordChangeDate { get; set; }
}

Related

Acumatica API Error when creating a Inventory Receipts API calls

Good day
I am creating a SOAP contract base connection to Acumatica.
I am getting an error: "System.ArgumentNullException: Value cannot be null."
I am not sure why I am getting the error.
Here is my code
using (var soapClient = new DefaultSoapClient())
{
try
{
soapClient.Login();
InventoryReceipt NewinventoryReceipt = new InventoryReceipt
{
ReferenceNbr = new StringValue { Value = "<NEW>" },
Hold = new BooleanValue { Value = true },
Date = new DateTimeValue { Value = DateTime.Now },
PostPeriod = new StringValue { Value = DateTime.Now.ToString("DD-yyyy") },
TransferNbr = new StringValue { Value = "" },
//External Ref
Description = new StringValue { Value = "" },
Details = new InventoryReceiptDetail[]
{
new InventoryReceiptDetail
{
//branch
InventoryID = new StringValue{Value = "NIS777"},
WarehouseID = new StringValue{Value = "FBTZEST"},
Location = new StringValue {Value = "BULK"},
Qty = new DecimalValue{Value = 1},
UOM = new StringValue{Value = "PALLET"},
UnitCost = new DecimalValue{Value = 91},
ExtCost = new DecimalValue{Value = 91},
LotSerialNbr = new StringValue{Value = "PLN12345"},
ExpirationDate = new DateTimeValue{Value = DateTime.Now},
// ReasonCode
Description = new StringValue{Value = ""}
}
},
};
InventoryReceipt putInventoryReceipt = (InventoryReceipt)soapClient.Put(NewinventoryReceipt);
}
catch (Exception ex)
{
soapClient.Logout();
throw;
}
finally
{
soapClient.Logout();
}
soapClient.Logout();
}
Console.ReadLine();
}
Is there any way to see what is null or what I am missing to post this data?
Have you tried manually entering the data into the UI? The Validation on the web service should be the same as the UI, so you might get more info from the UI. You have a lot of dependent values here since you're referencing a specific Lot perhaps a value is missing. Other than that, you might try adding Project = X.

How to create attributes on a Service Order through Web Services

I had to create my own Web Service Endpoint for Service Orders. Here is the WSDL: https://imagineersllc.acumatica.com/(W(7))/entity/PileraAPI/19.100.0122?wsdl&company=Imagineers%20LLC%20-%20Prototype I added Attributes to it following an example I found under Stock Items in the Default Endpoint.
I added attributes to the Service Order type and when I try to populate the attributes in my API they remain blank. The Service Order gets created just fine it just does not populate the attributes.
I've tried renaming the attributes and using the code vs the description in my code.
string sServiceOrderType = "MRO"; // Only type supported
string sCustomer = "1003";
string sBranchLocation = "PROPMGMT"; // Only location available
string sWorkflowStage = "ACKNOWLEDGED";
DateTime dDate = DateTime.Parse("7/1/2019");
string sExternalReference = "WO-2345";
string sDescription = "Service Order from Pilera API";
bool bOverride = true; // Used to make Contact and Address editable
string sCompanyName = "DSD Business Systems";
string sAttention = "John Wiles";
string sPhone = "(858) 550-5900";
string sEmail = "johnw#dsdinc.com";
string sAddressLine1 = "1225 Rosemarie Way";
string sAddressLine2 = "";
string sCity = "Chesapeake";
string sState = "VA";
string sPostalCode = "23322";
DateTime dPromisedDate = DateTime.Parse("7/21/2019");
string sSeverity = "Low";
string sPriority = "High";
string sComment = "Comment created by API";
bool bHold = true;
string sCategory = "GENERALREPAIR";
string sCommunity = "Deerfield Condominium Assoc.";
string sContact = "Annamma George";
string sContactPhone = "860-656-6603";
string sContactLocation = "268 Richard Street #1 Newington, CT 06111";
ServiceOrders ServiceOrdersToBeCreated = new ServiceOrders
{
ServiceOrderType = new StringValue { Value = sServiceOrderType },
Customer = new StringValue { Value = sCustomer },
BranchLocation = new StringValue { Value = sBranchLocation },
WorkflowStage = new StringValue { Value = sWorkflowStage },
Date = new DateTimeValue { Value = dDate },
ExternalReference = new StringValue { Value = sExternalReference },
Description = new StringValue { Value = sDescription },
Hold = new BooleanValue { Value = bHold },
PromisedDate = new DateTimeValue { Value = dPromisedDate },
Severity = new StringValue { Value = sSeverity },
Priority = new StringValue { Value = sPriority },
Category = new StringValue { Value = sCategory },
Override = new BooleanValue { Value = bOverride },
CompanyName = new StringValue { Value = sCompanyName },
Attention = new StringValue { Value = sAttention },
Phone = new StringValue { Value = sPhone },
Email = new StringValue { Value = sEmail },
AddressLine1 = new StringValue { Value = sAddressLine1 },
AddressLine2 = new StringValue { Value = sAddressLine2 },
City = new StringValue { Value = sCity },
State = new StringValue { Value = sState },
PostalCode = new StringValue { Value = sPostalCode },
Comment = new StringValue { Value = sComment },
Attributes = new[]
{
new AttributeValue
{
AttributeID = new StringValue { Value = "Community" },
Value = new StringValue { Value = sCommunity }
},
new AttributeValue
{
AttributeID = new StringValue { Value = "Contact" },
Value = new StringValue { Value = sContact }
},
new AttributeValue
{
AttributeID = new StringValue { Value = "Phone" },
Value = new StringValue { Value = sContactPhone }
},
new AttributeValue
{
AttributeID = new StringValue { Value = "Location" },
Value = new StringValue { Value = sContactLocation }
}
}
};
ServiceOrders newServiceOrder = (ServiceOrders)soapClient.Put(ServiceOrdersToBeCreated);
Service Order is created without attributes. No error messages received.
Here is what Support provided:
try
{
ServiceOrders newServiceOrder = (ServiceOrders)client.Put(ServiceOrdersToBeCreated);
List<AttributeValue> attrList = new List<AttributeValue>();
foreach (AttributeValue attrVal in newServiceOrder.Attributes)
{
AttributeValue attr = new AttributeValue();
attr.ID = attrVal.ID;
switch(attrVal.AttributeID.Value)
{
case "Community":
attr.Value = new StringValue { Value = sCommunity };
break;
case "Contact":
attr.Value = new StringValue { Value = sContact };
break;
case "Phone":
attr.Value = new StringValue { Value = sContactPhone };
break;
case "Location":
attr.Value = new StringValue { Value = sContactLocation };
break;
default:
Console.WriteLine("Attribute Not Found!");
break;
}
attrList.Add(attr);
}
newServiceOrder.Attributes = attrList.ToArray();
newServiceOrder = (ServiceOrders)client.Put(newServiceOrder);
}

ServiceStack OrmLite-Oracle: Can't insert object with sequence attribute

I'm testing ServiceStack.OrmLite.Oracle (5.5.1) but can't save data to database when create model with Sequence attribute. Try to test with API & generated SQL, API not insert data but generated SQL is correct. How to fix this?
using System;
using System.Data;
using NUnit.Framework;
using ServiceStack.DataAnnotations;
using ServiceStack.OrmLite;
namespace Tests
{
public class DatabaseTest
{
private readonly IDbConnection _db;
public DatabaseTest()
{
var dbFactory = new OrmLiteConnectionFactory(
#"Data Source = (DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ora-test)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = twcms12c))); User Id=scott; Password=Ab123456",
OracleDialect.Provider);
_db = dbFactory.OpenDbConnection();
}
[Test]
public void CustomerInsertTest()
{
_db.DropAndCreateTable<Person>();
var customer = new Person {FirstName = "John", LastName = "Smith", Age = 20};
//Insert by API not work
_db.Insert(customer);
var customers = _db.Select<Person>();
Console.WriteLine("Person count (API) = {0}",customers.Count);
//Insert by SQL working
_db.ExecuteSql(_db.ToInsertStatement(customer));
customers = _db.Select<Person>();
Console.WriteLine("Person count (SQL) = {0}",customers.Count);
}
}
public class Person
{
[AutoIncrement]
[Sequence("PERSON_SEQ")]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int? Age { get; set; }
}
}
And output result is:
Person count (API) = 0
Person count (SQL) = 1
In ServiceStack.OrmLite.Oracle (5.5.1) have a bug in method GetNextValue (ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.cs):
private object GetNextValue(IDbCommand dbCmd, string sequence, object value)
{
if (value.ToString() != "0")
{
object retObj;
if (long.TryParse(value.ToString(), out var nv))
{
LastInsertId = nv;
retObj = LastInsertId;
}
else
{
LastInsertId = 0;
retObj = value;
}
return retObj;
}
dbCmd.CommandText = $"SELECT {Quote(sequence)}.NEXTVAL FROM dual";
long result = (long)dbCmd.LongScalar();
LastInsertId = result;
return result;
}
I change it to:
private object GetNextValue(IDbCommand dbCmd, string sequence, object value)
{
if (value.ToString() != "0")
{
object retObj;
if (long.TryParse(value.ToString(), out var nv))
{
LastInsertId = nv;
retObj = LastInsertId;
}
else
{
LastInsertId = 0;
retObj = value;
}
return retObj;
}
var lastSql = dbCmd.CommandText;
dbCmd.CommandText = $"SELECT {Quote(sequence)}.NEXTVAL FROM dual";
long result = (long)dbCmd.LongScalar();
LastInsertId = result;
dbCmd.CommandText = lastSql;
return result;
}
and it work well.
P/s: I have create a pull request it was accepted by ServiceStack.

Acumatica change Shipping Terms on Sales Order creation

I'm using Acumatica's contract based API to create sales order from an ASP.net application. I need to update the "Shipping Terms" field under the "Shipping Settings" tab on a Sales Order when I create it (see below), but I can not find the property to use on the ASP.net objects that are provided through the contract based API. How would I accomplish this?
Here is my current code for how I create the sales order:
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
//Sales order data
string customerID = "CUST1234;
string orderDescription = "Automated Order";
string customerOrder = "TEST";
var orderDetails = new List<SalesOrderDetail>();
foreach(var lineItem in order.line_items)
{
orderDetails.Add(new SalesOrderDetail {
InventoryID = new StringValue { Value = lineItem.sku },
Quantity = new DecimalValue { Value = lineItem.quantity },
UnitPrice = new DecimalValue { Value = Decimal.Parse(lineItem.price) }, //TODO this should only be done for MHR owned sites
UOM = new StringValue { Value = "EACH" },
});
}
//Specify the values of a new sales order
SalesOrder orderToBeCreated = new SalesOrder
{
OrderType = new StringValue { Value = "SO" },
CustomerID = new StringValue { Value = customerID },
Description = new StringValue { Value = orderDescription },
CustomerOrder = new StringValue { Value = customerOrder },
ExternalReference = new StringValue { Value = order.order_number.ToString() },
Details = orderDetails.ToArray<SalesOrderDetail>(),
ShippingAddressOverride = new BooleanValue { Value = true },
ShippingContactOverride = new BooleanValue { Value = true },
ShippingContact = new Contact()
{
DisplayName = new StringValue { Value = order.shipping_address.first_name + " " + order.shipping_address.last_name },
FirstName = new StringValue { Value = order.shipping_address.first_name },
LastName = new StringValue { Value = order.shipping_address.last_name },
Address = new Address()
{
AddressLine1 = new StringValue { Value = order.shipping_address.address_1 },
AddressLine2 = new StringValue { Value = order.shipping_address.address_2 },
City = new StringValue { Value = order.shipping_address.city },
State = new StringValue { Value = order.shipping_address.state },
Country = new StringValue { Value = order.shipping_address.country },
PostalCode = new StringValue { Value = order.shipping_address.postcode }
}
},
};
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
//Create a sales order with the specified values
try
{
SalesOrder newOrder = (SalesOrder)await client.PutAsync(orderToBeCreated);
client.Logout();
return newOrder;
}
catch (Exception e)
{
//order addition to Acumatica failed, update the order status in Woo Commerce
client.Logout();
Console.WriteLine("Acumatica could not add specified entity: " + e);
return null;
}
}
UPDATE:
Based on PatrickChen's comment, I created a new web service endpoint in Acumatica "SalesOrderCustom", where I used all of the default fields and then added "ShippingTerms" to the list as well. I then imported that web service into my .net project (with some headache due to this issue) and was able to use the service to GET the sales order I wanted to add shipping terms to, and try to update it. The code executes ok, but after the PUT operation is done, the object is NOT updated in Acumatica and the ShippingTerms property is returned as NULL. What am I doing wrong? Code below:
public async Task<SalesOrderCustom> UpdateShippingTerms(string customerOrder, string originStore, string shippingSpeed)
{
var binding = CreateNewBinding(true, 655360000, 655360000);
var address = new EndpointAddress(ConfigurationManager.AppSettings["AcumaticaCustomUrl"]);
var soToBeFound = new SalesOrderCustom()
{
OrderType = new StringSearch { Value = "SO" },
CustomerOrder = new StringSearch { Value = customerOrder }
};
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
try
{
var soToBeUpdated = (SalesOrderCustom) await client.GetAsync(soToBeFound);
soToBeUpdated.ShippingTerms = new StringValue { Value = "USPS 1 CLS" };
var updatedOrder = (SalesOrderCustom)await client.PutAsync(soToBeUpdated);
//ShippingTerms is still NULL on returned object even after updating the object!!! WHY???
client.Logout();
return updatedOrder;
}
catch (Exception e)
{
client.Logout();
Console.WriteLine("Acumatica could not find specified entity: " + e);
return null;
}
}
}
Starting Acumatica 6, it's possible to update any field, not included into the Default endpoint. This feature is only available for endpoints implementing system contract of the 2nd version:
Below is the sample showing how to change Shipping Terms for a Sales Order with the Default Contract-Based endpoint by working with the CustomFields collection:
using (var client = new DefaultSoapClient())
{
client.Login("admin", "123", null, null, null);
try
{
var order = new SalesOrder()
{
OrderType = new StringSearch { Value = "SO" },
OrderNbr = new StringSearch { Value = "SO003729" }
};
order = client.Get(order) as SalesOrder;
order.CustomFields = new CustomField[]
{
new CustomStringField
{
fieldName = "ShipTermsID",
viewName = "CurrentDocument",
Value = new StringValue { Value = "FLATRATE2" }
}
};
client.Put(order);
}
finally
{
client.Logout();
}
}
No issues also noticed on my end when updating Sales Order Shipping Terms with the extended Default Contract-Based endpoint on a brand new Acumatica ERP 6.1 instance:
using (var client = new DefaultSoapClient())
{
client.Login("admin", "123", null, null, null);
try
{
var order = new SalesOrder()
{
OrderType = new StringSearch { Value = "SO" },
OrderNbr = new StringSearch { Value = "SO003729" }
};
order = client.Get(order) as SalesOrder;
order.ShippingTerms = new StringValue { Value = "FLATRATE1" };
client.Put(order);
}
finally
{
client.Logout();
}
}
For reference, adding screenshot of my extended Default endpoint used to update Shipping Terms in the SalesOrder entity:
I was able to add Shipping Terms when I created a new 6.0 endpoint. The default endpoint that ships with Acumatica is not extendable.

How to use the ThumbnailCard in IDialog Context

Hi I am developing one bot using Microsoft botframework project in that I am using IDialog interface. In that I am using the ThumbnailCard for displaying the cards. Here when I am attaching some data to my cards and the data is attaching properly but within the PostAsync method it’s not providing the reply.
public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
ThumbnailCard plCard = null;
IMessageActivity replyToConversation =await argument;
replyToConversation.Type = "message";
replyToConversation.Attachments = new List<Attachment>();
replyToConversation.Text = "welcome to book my show";
Dictionary<string, string> cardContentList = new Dictionary<string, string>();
cardContentList.Add("Jason Bourne", "URL");
cardContentList.Add("The Land", "URL");
cardContentList.Add("Yoga Hosers", "URL");
foreach (KeyValuePair<string, string> cardContent in cardContentList)
{
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: cardContent.Value));
List<CardAction> cardButtons = new List<CardAction>();
if (cardContent.Key == "Jason Bourne")
{
CardAction plButton1 = new CardAction()
{
Value = $"",
Type = "openUrl",
Title = "Book Now"
};
CardAction plButton2 = new CardAction()
{
Value = "tel:1-800-800-5705",
Type = "call",
Title = "Show timings"
};
cardButtons.Add(plButton1);
cardButtons.Add(plButton2);
plCard = new ThumbnailCard()
{
Title = $"Jason Bourne",
Subtitle = " ",
Images = cardImages,
Buttons = cardButtons,
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
}
else if (cardContent.Key == "The Land")
{
CardAction plButton1 = new CardAction()
{
Value = $"",
Type = "openUrl",
Title = "Book Now"
};
CardAction plButton2 = new CardAction()
{
Value = "tel:1-800-800-5705",
Type = "call",
Title = "Show Timings"
};
cardButtons.Add(plButton1);
cardButtons.Add(plButton2);
plCard = new ThumbnailCard()
{
Title = $"The Land",
Subtitle = "",
Images = cardImages,
Buttons = cardButtons,
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
}
else if (cardContent.Key == "Yoga Hosers")
{
CardAction plButton1 = new CardAction()
{
Value = $"",
Type = "openUrl",
Title = "Book Now"
};
CardAction plButton2 = new CardAction()
{
Value = "tel:1-800-800-5705",
Type = "call",
Title = "Show timings"
};
cardButtons.Add(plButton1);
cardButtons.Add(plButton2);
plCard = new ThumbnailCard()
{
Title = $"Yoga Hosers",
Subtitle = "",
Images = cardImages,
Buttons = cardButtons,
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
}
}
replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
await context.PostAsync(replyToConversation);
}
When I run the bot its show the following error
Can we use cards in IDialog Context for attachments?
The issue is with the IMessageActivity, you are trying to send IMessageActicity in context.PostAsync. That's the reason it is failing.
Do the following changes to make it work
Change the method signature like below
private async Task messageReceived(IDialogContext context, IAwaitable<object> argument)
and modify the IMessageActivity replyToConversation =await argument; to like below
var message = await argument as Activity;
Activity replyToConversation = message.CreateReply("Welcome." + "(Hi)");
replyToConversation.Recipient = message.From;
Now it should work, if you still have issue please comment here.
-Kishore

Resources