How to get a new column value by calling a custom function - json

I am really new with PowerBi. I need to read item id to parsing API then insert to table. In my case, this is what I have in the PowerBI
I need to get some data from ADO using API, then I create query like this picture below with this script:
let
    Source = Json.Document(Web.Contents("https://dev.azure.com/XXX/ProjectName/_apis/wit/workitems/3217?api-version=7.0")),
#"Converted to Table" = Record.ToTable(Source)
in
    #"Converted to Table"
My expectation is, I want to query the work item id from Backlog table to Query1. So in the Query1 I don't need to specify the work item id like this Json.Document(Web.Contents("https://dev.azure.com/XXX/ProjectName/_apis/wit/workitems/3217?api-version=7.0")), It will depend on the work item on Backlog, because the work item in the Backlog will update automatically on ADO if click refresh on powerbi.
Anyone can help me please, I really appreciate it, I know this is not easy :(

Related

Macro Design - After Update Audit Trail (MS Access)

I am new-ish to access scripting, but through brute force and the Uni of Google/Microsoft, I have been able to make some pretty nice DB's. I have two items that I am struggling with.
I am creating a AFTER UPDATE macro from the table that will track the changes to the fields and create a new table with the changes "old" and "new" values. So far it works well for the most part, but I am trying to two specific things:
1 - capture the value from a CBO and not the ID number.
2 - run a function from my VBA script.
For the item #1 here is a sample of my code from the macro designer for a CBO value. (sorry don't know how to add the code itself)
If [Eng_Units] <> [Old].[Eng_Units]
RunDataMacro
Macro Name = tbl_UnityExport.dmcr_AuditUnity
Parameters
par_Event = "Edited"
par_ID = [ID]
par_Field = "Eng Units"
par_OldValue = [Old].[Eng_Units]
par_NewValue = [Eng_Units]
End If
For the par_OldValue and par_NewValue, my Eng_Units comes from another table called tbl_Eng_Units but what is being returned is the ID of the tbl_Eng_Units or column(0) and not the actual text in column(1) of table. The table that is recording the changes is my audit table and as you can see, ID numbers don't help me understand what I have changed from and to, unless I actually go in a look at the id in my Eng_Units table
Audit Record sample See #65
Can someone tell me how to get the textual value of the record and not the ID?
Item #2 I have another database that someone else developed and using a function in the "Value =" field of the SetField item. My function in a VB macro is called GetUserName(). and this is how it was written in the old DB. I am at a loss other than there is some other script I can't find...anywhere.
Macro Designer for Function
How would I run a function from the "Named Macro"
Your help and expertise is appreciated!

How to Load Data into Tool Strip Combobox from Database

Does a converted combobox from toolstrip menu cannot display data from database? I'm trying to populate my converted combobox but when i tried to use .datasource and .displaymember it doesnt show from suggested list of keywords, converted combobox doesn't seem to support Data Bindings.
I find your text a bit unclear and contradictary as for what is actually wrong and desired. Hopefully, here is what you're after.
You've already got the data as DataSet named dataset. Here, be aware, you're missing a ValueMember, so let's assume it's only a DisplayMember you're after.
All you need to do is following:
' ToolStripComboBox1.ComboBox.ValueMember = "ID" ' you'd use it, if you wanted a ValueMember
ToolStripComboBox1.ComboBox.DisplayMember = "name"
ToolStripComboBox1.ComboBox.DataSource = dataset.Tables(0)
If you want to select pre-defined item:
ToolStripComboBox1.ComboBox.SelectedIndex = 3
If you want to get selected item:
Dim StrSelected as String
StrSelected = ToolStripComboBox1.ComboBox.GetItemText(ToolStripComboBox1.ComboBox.SelectedItem)
If it's AutoComplete source giving you problems, you probably wan't to set:
ToolStripComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems
But I get a feeling, that you're confused and you actually don't need anything related to AutoComplete, since you also set:
ToolStripComboBox1.AutoCompleteMode = AutoCompleteMode.None
...which is contradicting "show from suggested list of keywords". That's why I initially thought you're actually not seeing anything in your ComboBox, because you didn't provided DisplayMember and DataSource.
If you want to include a value member, first include it into SQL query:
SearchQuery = "select ID,name from pis.roles"
Then uncomment row above with Value member and it will be loaded (with no visible effect).

MS Access 2010- How to update field on one table based on field in another table

I'm designing a database to track requests. Currently, I have a form that its' record source is based off a query "Unassigned Requests". This query is based off my table Requests, and returns all "unassigned Requests". In this form, I would like the status field to change to "Assigned", once a Tech field has been assigned to the request. I currently have the Default for the Tech Assigned field set to "Blank', and the status field set to 'Unassigned". Both of these fields are combo boxes. The status field has a control source from the request table and row source from the status table. The tech assigned field has a control source from the Tech table and the row source is based off a query.
I have tried multiple solutions that have not seemed to work. I have limited experience with Macros and VBA. I would appreciate any suggestions on solving this problem.
I am going to make some assumptions regarding your post and if any are incorrect please let me know.
You have a request form where a request is assigned to a Tech. On that form there is a dropdown for the status, and also for the Tech.
You want to make it so when the tech dropdown is filled out with a tech's name you want the dropdown to change to assigned.
If this is the case I would recommend using the Tech Assigned field's AfterUpdate event. The code would look something like this:
Private Sub cboTech_Assigned_AfterUpdate()
If Nz(Me.cboTech_Assigned.Value, "") <> "" Then
Me.cboStatus = "Assigned"
Else
Me.cboStatus = ""
End If
End Sub
Obviously you will need to adjust to your own naming scheme. I should also point out that I don't even know if that Nz function is needed, I have just gotten into the habit of putting it everywhere. If I misunderstood something about what you want to do please let me know!

Updating a single row in TaffyDB

I currently have a database setup within an html page and my requirement is to update a single row within the application.
I could refresh the database with "fresh" data, but that would require too much time.
I had a look at
dbSports().update("aName", object.aname);
However it seems to update all the records in my database instead of just one. Are there any answers to this particular issue?
The Documentation on the matter is missing a major chunk of information, but is covered in a presentation done by the author of the library (http://www.slideshare.net/typicaljoe/better-data-management-using-taffydb-1357773) [Slide 30]
The querying object needs to be pointing to the object you want to update and editing happening from there. i.e.
var obj = dbObject({
Id : value.id
}).update(function() {
this.aName = object.aname;
return this;
});
Where the object in the query points to the ID of the row and the update function then points to it aswell and the callback updates the value that the application needs to update
you first have to find the matching record, then update it
yourDB({"ID":recordID}).update({
"col1":val1,
"col2":val2,
"col3":val3
});

Examples of how to create text fields, size them, and put them in columns on a report

The 1,500 page Access 97 Bible (don't laugh!) that I've been given by my boss to solve his problem doesn't solve my problem of how to solve his problem, because it has nee VBA code.
Let me first make clear that I've made attempts to solve this without (much) coding, and that I've coded quite a bit in VBA already, so I'm basically familiar with most things including recordsets, queries, etc etc but have problems with MS Access limits on how to form a report with data coming from VBA variables. I'm also versatile in most programming languages, but this is not a language problem but rather a "how to/what's possible" problem.
My problem right now is that dragging the query fields into the Detail subform and putting them into cells in columns setting Left and Top with VBA code are moving them alright, but each cell is on a new page. Unfortunately, there is multiple data in each cell that won't conform to the Create Report Guide options available.
So my question is simply this: Can someone point me to working examples of code that create, place, and fill with VBA variable strings, text fields at any coordinate I please on a paper size of my choice?
Edit: The above is not an option, as I understand this will prohibit the client from getting an .mde database. What remains, then, is to merely ask for some sound advice on how to get several rows GROUPed BY weekday and machine (see below) into a recordset or similar for each cell. I guess the best way is to count the number of columns in the table (machines in the sql result) and create 5 rows of these with dummy data, then go through the result rows and place the data in the relevant controls. But if you have ideas for doing this work better and faster, write them as answers.
Sorry for this, I knew there was something I wasn't understanding. Basically, I thought Access supported creating reports dynamically via VBA, ie. "generating pages with data" rather than "preparing a flow of controls connected to datasources". But Access requires that you create an ample amount of dummy, unlinked controls manually, then either fill or hide them and that's how they become "dynamic".
This is for Access 2003 on a remote server accessing local and remote ODBC SQL database tables, if relevant. The goal is to make a week schedule of n columns (n=number of machines at a certain plant) x 5 rows (weekday Mon-Fri), and put 1 or more recordset rows (=scheduled activities for that day on that machine) in each of the "n by 5 table" cells.
If you detect venting frustration in this post I can only ask your forgiveness and hope for your understanding.
So, has many techniques for this:
Ex: 1) using dinamic sql for this:
'Create a function to make sql query
Function MakeMySQlReport(Parameters):
Dim strSql as string
Dim strMyVar as string
strsql = vbnullstring
strsql = "Select " & myVar1 & " as MyFieldVar1, * from myTable where Fieldx =" & Parameters
MyReport.recordSource = ssql
End Function
Ex: 2) create function that returns yours strings:
Function MyString1() as string
MyString1 = 'ABC'
end Function
An in your report, select the textbox will receive the value and type =MyString1()]
I hope this help to you, need more examples?
Solution:
Create many objects manually (grr!)
name them systematically
put them in a Control Array (get all Me.Controls, sift out the ones you're interested in, and put them in an indexed array)
go through the array and change their properties