Working on a bot for teams using the Bot Framework SDK, I noticed that the AdaptiveChoiceSetInput (dropdowns) in cards don't behave the same way on mobile and desktop devices.
On desktop Teams, if a dropdown does not have a value, it defaults to a placeholder Select. This automatic defaulting also allows for validation to force a choice to be selected from the dropdown.
On mobile Teams, if a dropdown does not have a value, it instead defaults to the first choice. This is obviously incorrect as it makes it appear like a choice is selected in the dropdown, when it's really null.
A solution I tried was to manually add a default choice with value of null so that it would automatically set itself on mobile if the value was null. This caused an issue where the card did not appear on a mobile device.
Another solution was to add a value, like 0. Although it's likely possible to make things work this way, it lead to some complicated code I never finished because on desktop I had to account for the placeholder and the manually added default choice, and figure out how to prevent the form to be submitted with the manually added default choice.
How can I make the AdaptiveChoiceSetInput behave the same way on mobile version of Teams as in the desktop version?
Here's the relevant code:
private async Task<Attachment> GetEditableOrder(OrderModel order)
{
List<AdaptiveChoice> orderAdaptiveChoices = _context.GetOrderAdaptiveChoices(order.id);
var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0));
card.Body.Add(new AdaptiveColumnSet
{
Columns = new List<AdaptiveColumn>
{
new AdaptiveColumn
{
Items = new List<AdaptiveElement>
{
new AdaptiveTextBlock
{
Text = "**Order**"
}
}
},
new AdaptiveColumn
{
Items = new List<AdaptiveElement>
{
new AdaptiveChoiceSetInput
{
Id = "orderId",
Choices = orderAdaptiveChoices,
Value = order.Id.ToString(),
Style = AdaptiveChoiceInputStyle.Compact,
Placeholder = "Select",
IsRequired = true,
ErrorMessage = "Selection required."
}
}
}
}
});
card.Actions.Add(new AdaptiveSubmitAction
{
Type = AdaptiveSubmitAction.TypeName,
Title = "Submit",
Data = new JObject {
{ "submitLocation", "editOrder" }
},
});
Attachment attachment = new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = card
};
return attachment;
}
I solved my issue by manually adding an additional default choice titled "Select" with the value of an empty string. The values null and 0 did not work due to the issues I mentioned in my question. But an empty string seems to behave the same way as the placeholder in desktop version of Teams.
So, to make the dropdown in the cards behave the same way on desktop and mobile version of Teams, simply prepend a default AdaptiveChoice to your list with the value of an empty string:
orderAdaptiveChoices.Insert(0, new AdaptiveChoice { Value = "", Title = "Select" });
Whenever it is selected on either device, it will function the same way as the placeholder that is available only on desktop Teams.
Related
I am trying to have fields in my template be populated when I call the post request of my API, currently I am getting the template which I created in DocuSign's Template creator. But I need to be able dynamically change these fields contents.
How do I find the custom field which I created? I am currently using TextCustomField. The only thing I can see which would find the custom field is FieldId but there is no option on the website to set or find one. So I am not sure what to do from here. Here is a code snippet to how I have tried it so far, to no success.
I a junior developer and I am new to docusign, and I feel that the documentation leaves a lot to be desired.
CustomFields cf = new CustomFields();
cf.TextCustomFields = new List<TextCustomField>();
TextCustomField tcf = new TextCustomField();
tcf.FieldId = "001";
tcf.Name = "test";
tcf.Value = "NewValueFor test_field_1";
cf.TextCustomFields.Add(tcf);
env.CustomFields = cf;
I set the data label on the website to 001.
Looks like there's been a misunderstanding in DocuSign vocabulary. Your screenshot shows a "field", which in eSignature API terms is a "tab". The TextCustomField object you currently have would be used to populate an Envelope Custom Field - not what you're currently trying to do.
If you've placed that tab on your template, then you can populate it's value by creating a TextTab object and assigning it to your signer's list of tabs like so. The TabLabel aligns with the web console's Name parameter, and the Value is what you want to populate it with.
Text exampleTab1 = new Text //Create the Tab definition
{
Value = "Example Value",
TabLabel = "test_field_1",
};
Signer signer1 = new Signer //Create a Signer
{
Email = signerEmail,
Name = signerName,
RecipientId = "1",
RoutingOrder = "1",
};
Tabs signer1Tabs = new Tabs //Assign Tab to Signer
{
TextTabs = new List<Text> { exampleTab1 }
};
You probably can leverage the C# feature called LINQ, you need to add the following namespace to your class:
using System.Linq;
And then you can find your objects with this code:
var mycustomField = cf.TextCustomFields.FirstOrDefault(f => f.FieldId == "MYIDENTIFICATOR");
Can we check whether the input form in an adaptive card is filled or not with a warning message.
I am currently using an adaptive card to gather user input in bot application,I have already added isRequired for input validation but it doesnot give any warning message instead when I click on submit it doesnot go to the next method.
As soon as the user presses submit I want to make sure that the form is not empty
If you have an Adaptive Card like this (notice the ID given to the input):
var card = new AdaptiveCard
{
Body =
{
new AdaptiveTextBlock("Adaptive Card"),
new AdaptiveTextInput { Id = "text" },
},
Actions = {
new AdaptiveSubmitAction { Title = "Submit" } },
},
};
You can validate the value sent through the submit action like this:
if (string.IsNullOrEmpty(turnContext.Activity.Text))
{
dynamic value = turnContext.Activity.Value;
string text = value["text"]; // The property will be named after your input's ID
var emailRegex = new Regex(#"^\S+#\S+$"); // This is VERY basic email Regex. You might want something different.
if (emailRegex.IsMatch(text))
{
await turnContext.SendActivityAsync($"I think {text} is a valid email address");
}
else
{
await turnContext.SendActivityAsync($"I don't think {text} is a valid email address");
}
}
Validating email with regex can get very complicated and I've taken a simple approach. You can read more about email Regex here: How to validate an email address using a regular expression?
I took totally different approach than the accepted answer here. If you are going to use adaptive cards a lot in your bot than it makes sense to create card models and have validation attributes applied to each field that needs validation. Create custom card prompt inheriting from Prompt<object> class. Override OnPromptAsync and OnRecognizeAsync and check the validation of each field there.
I have look around the other post about this Project Backlog, but i want to those missing field in this image here
I need those missing fields like workitem, Title, Assigned To, State, Effort, Business.
I have this code with me right now.
/ Set up default team sprint date and time
var teamConfig = _tfs.GetService<TeamSettingsConfigurationService>();
var css = _tfs.GetService<ICommonStructureService4>();
string rootNodePath = string.Format("\\{0}\\Iteration\\Release 1\\Sprint 1", _selectedTeamProject.Name);
var pathRoot = css.GetNodeFromPath(rootNodePath);
css.SetIterationDates(pathRoot.Uri, DateTime.Now.AddDays(-5), DateTime.Now.AddDays(7));
var configs = teamConfig.GetTeamConfigurationsForUser(new[] { _selectedTeamProject.Uri });
var team = configs.Where(c => c.TeamName == "Demo").FirstOrDefault();
var ts = team.TeamSettings;
ts.BacklogIterationPath = string.Format(#"{0}\Release 1", _selectedTeamProject.Name);
ts.IterationPaths = new string[] { string.Format(#"{0}\Release 1\Sprint 1", _selectedTeamProject.Name), string.Format(#"{0}\Release 1\Sprint 2", _selectedTeamProject.Name) };
var tfv = new TeamFieldValue();
tfv.IncludeChildren = true;
tfv.Value = _selectedTeamProject.Name;
ts.TeamFieldValues = new []{tfv};
teamConfig.SetTeamSettings(team.TeamId, ts);
According to your screenshot, seems you are using the Work item Summary web part. After the upgrade to TFS2018, your TFS SharePoint sites will display, but all integration functionality is disabled.
The official recommended way is using TFS Dashboards for a better way to create dashboards. From that it's more easy to track/display the fields in a work item.
You could directly use some 3-party Work Item widget such as this one which also provides a summary for a selected work item.
To get or update work items such as product backlog fields pro grammatically, you could use Rest API-- Get a list of work items to handle this. It will also return all related fields name and value. Which also include a C# (GetWorkItemsByIDs method) sample code. About how to customize a dashboard in sharepoint, please take a look at this thread.
I am using DocuSign SOAP API in an ASP.NET app in C# to send some docs for e-signature.
One of the field is the title tab. I have the following code for that.
When testing, the tab correctly shows the title, which is picked up from the back-end DB. But when I see the completed document, the title is changed to something else. Does anyone know how can I resolve this?
When signing, if I modify the value - add and remove space - it works OK.
tab5 = new DocuSignAPI.Tab();
tab5.RecipientID = rcpt1.ID;
tab5.DocumentID = docId;
tab5.Type = DocuSignAPI.TabTypeCode.Custom;
tab5.CustomTabType = DocuSignAPI.CustomTabType.Text;
tab5.Name = "clientTitle";
tab5.CustomTabTypeSpecified = true;
tab5.Value = (dr["Rcpt_1_Role"]).ToString();
tab5.Type = DocuSignAPI.TabTypeCode.Title;
tab5.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab5.AnchorTabItem.AnchorTabString = "CLIENT TITLE:";
tab5.AnchorTabItem.Unit = DocuSignAPI.UnitTypeCode.Pixels;
tab5.AnchorTabItem.UnitSpecified = false;
tab5.AnchorTabItem.IgnoreIfNotPresent = true;
tab5.AnchorTabItem.UnitSpecified = true;
tab5.AnchorTabItem.YOffset = -10;
tab5.AnchorTabItem.XOffset = 100;
When using certain DocuSign tab types (such as titleTabs or emailTabs for instance) the DocuSign platform will populate some of that information from the user's account if they have one.
For example, if the user has a DocuSign account where they have entered the title "CEO", then whenever you send an envelope to that exact recipient (name and email combo) and you use a titleTab the system will populate from their account.
I do not believe there is a way to override this, probably your best option is to just use a textTab instead and with that you can populate with any data from a database or wherever else you want to supply it from.
What do I need to do to mark an ItemFulfillment as shipped, including package information and possibly a different shipping method/carrier using SuiteTalk? We use WMS Lite RF Mobile Screen to initially create the ItemFulfillment, then a custom app to ship it.
I initially tried using an ItemFulfillmentPackageList to specify the package, but it seemed to ignore what I specified and add a default package (0.05 lb, no description or tracking).
I then tried ItemFulfillmentPackageUspsList, etc. and correct package information appeared if it matched the carrier previously specified in the order and fulfillment record. If it doesn't match, I get an error "[Code=JS_EXCEPTION] Error: Switching the shipping method to another carrier is an unsupported operation, because it requires reloading the item fulfillment form for that carrier." We need the ability to switch carriers because we offer free shipping for some orders, which ends up being "pick the cheapest rate for the package from the rates offered by the main 3 carriers".
//curShipment is an EasyPost shipment after purchasing postage.
//it contains relevant information about the package
ItemFulfillment fulfillmentUpdate = new ItemFulfillment();
fulfillmentUpdate.internalId = curFulfillment.internalId;
fulfillmentUpdate.shipStatus = ItemFulfillmentShipStatus._shipped;
fulfillmentUpdate.shipStatusSpecified = true;
fulfillmentUpdate.shipMethod = new RecordRef()
{
// Get the internalId from a saved dictionary
internalId = shipMethods.GetNetsuite(curShipment.selected_rate).netsuiteId
};
switch (curShipment.selected_rate.carrier)
{
case "USPS":
ItemFulfillmentPackageUsps pkgUsps = new ItemFulfillmentPackageUsps();
pkgUsps.packageWeightUsps = curShipment.parcel.weight / 16; // Easypost uses Oz, Netsuite uses Lb
pkgUsps.packageWeightUspsSpecified = true;
if (string.IsNullOrWhiteSpace(curShipment.parcel.predefined_package))
{
pkgUsps.packageLengthUsps = (long)curShipment.parcel.length;
pkgUsps.packageLengthUspsSpecified = true;
pkgUsps.packageWidthUsps = (long)curShipment.parcel.width;
pkgUsps.packageWidthUspsSpecified = true;
pkgUsps.packageHeightUsps = (long)curShipment.parcel.height;
}
pkgUsps.packageTrackingNumberUsps = curShipment.tracking_code;
ItemFulfillmentPackageUspsList pkgListUsps = new ItemFulfillmentPackageUspsList();
pkgListUsps.packageUsps = new ItemFulfillmentPackageUsps[] { pkgUsps };
fulfillmentUpdate.packageUspsList = pkgListUsps;
break;
// Cases for the other carriers, almost identical to USPS above
}
SetNetsuitePrefs(); // Sets preferences and authenticates, similar to the ERP example code
WriteResponse response = await System.Threading.Tasks.Task<SearchResult>.Run(() => { return nsService.update(fulfillmentUpdate); });
// Results in error:
// [Code=JS_EXCEPTION] Error: Switching the shipping method to another carrier is an unsupported operation, because it requires reloading the item fulfillment form for that carrier.
Try setting shipMethod to the RecordRef for the Shipping Item you will be using. If the SO was entered with a FedEx Shipping Item and now you want to use UPS, then set shipMethod accordingly and use the carrier-specific package list structure.