How can I use Json patch document using VB.net - json

I'm struggling to use the Add method for Json Patch Document in vb.net? My goal is to create work items programmatically. I'm looking to add values to Title, Description and Priority field of a work item. Do I have to use the same code separately for all three fields?
Also, I'm new to all this development stuff so encouragement would be appreciated. Here is my mini code - just updated. Can anyone tell me if I'm doing it the right way.
Dim JPDocument As New JsonPatchDocument
With JPDocument
.Item(0).Operation = Operation.Add
.Item(0).Path = "/fields/System.Title"
.Item(0).Value = "Visual basic rocks"
End With
Thanks,
Omar

Related

Get new Invoice ID when created via API using JSON

I have been using XML to create invoices but I am updating my code and switching to using JSON.
When using XML I would get a set of XML returned and part of the data was the new Invoice ID.
However, so it seems at least, when I create a new invoice via the API using JSON, I just get "http/200" (or something like that) returned and no info about what the new invoice ID is!
I need the invoice ID so I can post an attachment.
I tried adding "?summarizeErrors=false" to the end of the URL but nothing was returned unless there was an issue - kinda what it says it does :-)
Can anyone point me in the right direction?
Thanks, Jeremy
Its Ok....I resolved it. Wrong value populated in a property in the HTTP control I was using...ugh.

Passing Variables Between Forms

Forgive me if this has already been asked- I can’t seem to find a well written answer.
I am developing a small application for personal use.
Essentially what I have is two forms. Form 1 is a master view of all my contacts listed on a data grid view. Form 2 will be loaded on the cell/row double click of a particular record in order to edit it’s details.
My question is, what is the best practice/method for achieving this? I have seen many different methods.
Should I:
Pass only the primary key of the selected row then populate the fields on form 2 load
Pass all fields as a variable within a class then populate form 2 from that
Maybe I’m headed in the complete wrong direction though.
I have tried both ways, but wondering what the best method is for scalability.
My personal preference would be to pass a datarow into the opening argument of the form (rather than the PK / all the variables). You can then use the datarow inside your Form2 to bind to your controls or set their values, whichever you think is appropriate.
There are some useful examples on working with a datarow if you're unsure, alternatively you can also check out Microsoft Docs.
Public Sub New(ByVal row As DataRow)
InitializeComponent()
' your code for working with row here
End Sub
Edit:
In terms of "Binding" vs "Setting", you can either have your controls linked to your data to be two way (as you edit the data in a control at run time you alter the data in your database) or you can just set the values of the controls.
E.G. TextBox1.Text = row(0)("ColumnName")
You can find more on data binding on the Microsoft Docs page

Difficulties with constructing path to desired element?, Excel VBA

I'm new to VBA, trying to learn it. Facing a minor problem in extracting one data point from html.
Below is the html
{ div class="category">Category: Shopping
I just want to extract ( Shopping ) from this but what I'm getting is (Category:Shopping).
I'm using this code
html.querySelector(".category").innerText
Thanks in advance.
I would say the simplest is to use Replace$
data = Replace$(html.querySelector(".category").innerText,"Category:", vbNullString)
You could possibly use split
data = Trim$(Split(html.querySelector(".category").innerText,"Category:")(1))

Shortening this simple code in Actionscript?

http://imgur.com/3wJBwl6
As you can see on the picture, I have a stupidly long code, just to get the information I want in the Comboboxes. Is there any way to make it so I dont need that long of a code?
The comboboxes should display the same information, yet be able to record different "results"
Im obviously a beginner programmer. Help would be appreciated.
First, create an array with the data you need, for example:
var dataArray:Array = [{label:"label1", data:"data1"}, {label:"label2", data:"data2"}];//as many objects as you need.
then name the dropdown lists and use the "dataProvider" property to populate it:
dropdown1.dataProvider = new DataProvider(dataArray);
dropdown2.dataProvider = new DataProvider(dataArray);
dropdown3.dataProvider = new DataProvider(dataArray);
....
P.S. don't forget to import:
import fl.data.DataProvider;

How to do php operations in drupal

I am absolute beginner to drupal.
I have added a contact form (using Webform module).
Now I want to save the data entered in the form. But I am lost. I have searched over internet, found db_query() is used to query database.
But I dont know where to write the php code. Please help me or if you know any link,please give me.
The tables you'll be most interested in are webform, webform_submissions, webform_submitted_data and webform_component. Have a look at those tables and it becomes very obvious how they're linked together.
You'll want to look at the Drupal 7 Database API to learn how to use the query system but here's an example to get you going:
/* Get a list of all submissions from webform for the node with ID (`nid`) of 1 */
$nid = 1;
$submissions = db_select('webform_submissions', 'ws')
->fields('ws')
->condition('nid', $nid)
->execute();
/* If you want to use db_query and a plain old SQL statement instead you'd do it like this:
$submissions = db_query('SELECT * FROM webform_submissions WHERE nid = :nid', array('nid' => $nid)); */
/* Loop through the submissions and load up the submitted data for each */
$submission_data = array();
foreach ($submissions as $submission) {
$query = db_select('webform_submitted_data', 'wsa')
->fields('wc', array('name'))
->fields('wsa', array('data'))
->condition('sid', $submission->sid);
/* Join in the component table to get the element label */
$query->join('webform_component', 'wc', 'wc.nid = wsa.nid AND wc.sid = wsa.cid');
$submission_data[] = $query->execute()->fetchAllKeyed();
}
At the end of that code you'll have an array ($submission_data), which contains a list of arrays of submission data for the provided node. Each of those arrays' items has a key of the component label, and a value of the submitted user value.
Hope that helps
It's worth noting that for most normal use cases you'll never need to look at the databases or do any kind of coding. The UI allows you to view submissions of a form (and see what was submitted). You can also configure the Webform to send you a copy of each submission (via email)... There is a lot you can do without "looking under the hood" or messing with the database in any way.
If you are really new to Drupal and Webforms, I just thought I'd point that out. There are a lot of tabs in the UI which might easily be overlooked.
Webform has Views support, so you probably don't really need to write database queries to generate the report you want.