I implemented the calendar using that thread.
I'd like to consult data from MySql to Calendar.
I saved on MySql the data of an entity called shedule:
export class Schedule
{
code: number;
clas: string;
room: string;
teacher: string;
module: string;
startDate: Date;
endDate: Date;
}
I'm asking if I can show the details of that entity (schedule) on calendar ?.
It's possible to do that without using CalendarEvent ?.
Big thanks.
In order to show events on Angular-Calendar, I have to use CalendarEvent.
There's no documentation that allows to fetch data directly from an entity like schedule.
To resolve my problem, I have to use CalendarEvent like a bridge in that case.
Related
I am currently working on a powerapps app, and I have multiple pages with forms and different SharePoint lists connected to it. But every code I tried for submitting the data to the SharePoint doesn‘t seem to be working. Does anyone have any ides?
Patch('5S Fragen_1';varFormData1; Form1.Updates; Form3.Updates; Form3_1.Updates; Form3_2.Updates; Form3_3.Updates; Form3_4.Updates; Form3_5.Updates; Form3_6.Updates; Form3_7.Updates;Form3_8.Updates;Form3_9.Updates;Form3_10.Updates;Form3_11.Updates; Form3_12.Updates;Form3_13.Updates;Form3_14.Updates;Form3_15.Updates;Form3_16.Updates;Form3_17.Updates;Form3_18.Updates;Form3_19.Updates;Form3_20.Updates;Form3_21.Updates;Form3_22.Updates)
5S Fragen_1 is the name of my SharePoint List and varFormData1 is the item name
You will probably need to write Patch function in a different way:
Patch('5S Fragen_1';varFormData1; {Column1:textbox1.Text, Column2:Textbox2.Text, Column3Number:Value(Textbox3.Text)})
Alternatively, if you are using Forms, you can simply use SubmitForm(FormName1);SubmitForm(Form2); and so on.
Explanation: One way to write a Patch function is:
Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])
Datasource: SharePoint, SQL, Dataverse, etc
BaseRecord: A "record" Type object in Power Apps.
LookUp(DataSource, ID = Value(Textbox1.Text))
or
{ID:Value(Textbox1.Text)}
or
First(DataSource)
or
Defaults(DataSource) - this creates a brand new record in your datasource
ChangeRecord1: What you want to change in that BaseRecord object
{
Title: Box1.Text, //(or maybe ; instead of ,)
Status: dropdown.Selected.Value
//....
}
I'm trying to build a simple query on TypeORM but I'm not getting the entire data using INNER JOIN. What am I doing wrong?
The SQL query runs perfectly but the typeorm one just returns me the data for the 'watcher' table.
SQL Query
SELECT *
FROM watcher w
INNER JOIN user
ON w.userId = user.id;
TypeORM
async getSystemWideWatchers(): Promise<any[]> {
const query = this.createQueryBuilder('watcher');
const result = await query.innerJoin('user', 'u', 'watcher.userId = u.id').getMany();
console.log(result)
return result;
}
TypeORM has a method called innerJoinAndSelect. You use plain innerJoin. That is why user table is not selected from.
Once you change that part to innerJoinAndSelect, watch table will be selected from. However, getMany and getOne returns objects with your Entity type. Therefore, if your Entity types do not have the relationships between User and Watcher tables, selected columns will not be included in the returned object.
Before I show you how to add these relations, I want to mention that you have the option to use getRawMany function to get all selected columns, but I don't recommend using it, since relationships are much tidier (no raw column names, you get arrays of Entities corresponding to relationships) and in your case, there is no reason not to use relationships.
Now, the way I understand your database design, you have Users, and Users have Watchers. A Watcher watches only one User, and there may be multiple Watchers that watch the same user.
In this case, the relationship of User to Watcher is called "One to Many".
The relationship of Watcher to User is called "Many to One".
You need to specify this information in your Entity. Here is an example. Notice the OneToMany decorator.
#Entity()
export class User {
#PrimaryColumn()
id: number;
#Column()
userName: string;
#OneToMany(type => Watcher, watcher => watcher.user)
watchers: Watcher[];
}
Here is the corresponding Watcher Entity:
#Entity()
export class Watcher {
#PrimaryColumn()
id: number;
#Column()
watcherName: string;
// we can omit this (and the join condition), if userId is a foreign key
#Column()
userId: number;
#ManyToOne(type => User, user => user.watchers)
user: User;
}
Once you have these relationships, you can select a User, along with all their Watchers, or vice versa (select a Watcher with the User they watch).
Here is how you do both:
// Select a user and all their watchers
const query = createQueryBuilder('user', 'u')
.innerJoinAndSelect('u.watchers', 'w'); // 'w.userId = u.id' may be omitted
const result = await query.getMany();
(If you want to include users with no watchers, you use leftJoin instead of innerJoin, as you probably know.)
This is probably what you were initially trying to do:
// Select a watcher and the user they watch
const query = createQueryBuilder('watcher', 'w')
.innerJoinAndSelect('w.user', 'u'); // 'w.userId = u.id' may be omitted
const result = await query.getMany();
Just in case someone runs into another scenario. Adding to what Cem answered.
If there's no relationship defined in the database then you can do the following :
const query = createQueryBuilder('user', 'u')
.innerJoinAndMapMany(
'u.ObjectNameToMapDataOn',
EntityName,// or 'tableName'
'IAmAlias',
'u.columnName= IAmAlias.columnName'
)
similarly , innerJoinAndMapOne can be used. Depends on your case if you expect to have multiple records with joining table or single record.
if there isn't relations between the two tables, you will have to use getRow().
getOne() and getMany() will return object with type of your repository, and so drop the data of the joined table
this example works for me:
this.userRepository
.createQueryBuilder('user')
.select(['user.username as username', 'o.orderTime as orderTime'])
.where('user.id = :id', {id})
.andWhere('o.callerId = :id', {id})
.innerJoin(OrderEntity, 'o')
.getRawMany()
The data I store is at the moment written in english. So I plan to make this content localized/translatable and would like to give this option to users.
Here are my user stories:
(1) As a user I want to select the preferred language of my content (e.g. german). If the text is not available in german, please give me the content in the fallback language (e.g. english).
(2) As a user I want to be able to translate a given model.
Given the following:
1) A model, e.g. Message with two properties: title and description. It can be expected these two properties are in english (by default).
2) A command, e.g. translateMessage which will receive a payload with: title, description and locale.
What's an accepted way to handle localization of those models?
A solution I come up with:
Let's say our Message will have the following properties (in Typescript):
{
title: string;
description: string;
}
I would extend it with a translations object. Where each key in there is a locale and has an object with translated strings.
{
title: string;
description: string;
translations: {
[key: string]: {
title: string;
description: string;
}
}
}
The readModel will be the same as above and it is up to the client to decide which strings to display.
The command translateMessage will receive the payload as described above and publish an event with that. The readModel will react to that event in a way, that it pushes the new payload data onto the translations object in that model.
For model creation, if the data is received in a different locale than the default one, then the event handler will put those translated strings prefix with the locale they were written in, into the root, e.g. model.title can be something like [de] Nachrichtentitel. The model would look like this:
{
title: '[de] Nachrichtentitel'
description: '[de] Nachrichteninhalt'
translations: {
de: {
title: 'Nachrichtentitel'
description: 'Nachrichteninhalt'
}
}
}
You see any problems with that? Are there other already established best-practices on how to do that?
I am just starting out with Firebase and have managed to send data to a Firebase Realtime Database. The problem is that some times it works and sometimes not. I am struggling to understand why.
Here is a code snippet
var pq_data = jsPsych.data.get().values();
for (var ix= 0; ix < pq_data.length; ix++){
var object=pq_data[ix];
var pq_boo = pq_database.ref(subj_id +ix.toString()+'/').update(object)
}
As I say this works sometimes but not always and I understand that it may have something to do with the code completing before the write operations have(?)
I have read but do not clearly understand advice about onCompletion and I am still in the dark. I need to make sure each object is written to the database - is this possible and if so how?
Very much a beginner,
Philip.
// Import Admin SDK
var admin = require("firebase-admin");
// Get a database reference to our blog
var db = admin.database();
var ref = db.ref("server/saving-data/fireblog");
First, create a database reference to your user data. Then use set() / setValue() to save a user object to the database with the user's username, full name, and birthday. You can pass set a string, number, boolean, null, array or any JSON object. Passing null will remove the data at the specified location. In this case you'll pass it an object:
var usersRef = ref.child("users");
usersRef.set({
alanisawesome: {
date_of_birth: "June 23, 1912",
full_name: "Alan Turing"
},
gracehop: {
date_of_birth: "December 9, 1906",
full_name: "Grace Hopper"
}
});
Thanks for this Yes For brevity I didn't show all the code and so I have access to the database. The problem is with sending data to it. Sometimes it works and sometimes not.
I now realise this is related to my failure to deal with Promises. I have now some understanding of these but still need to make sure that the data gets captured in the database. SO even though the Promise may return an Error I still need to re-send the data so that it will get written to the database. Still not sure whether this is advisable or even possible.
How can I call a stored procedure in Acumatica via PXDataBase which has as input parameter User defined type?
For example, I have the following type:
CREATE TYPE [dbo].[string_list_tblType] AS TABLE(
[RefNbr] [nvarchar](10) NOT NULL,
PRIMARY KEY CLUSTERED
(
[RefNbr] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)
GO
I have the following stored procedure:
CREATE PROCEDURE [dbo].[GetListOfAPInvoices]
#APInvoices as string_list_tblType readonly,
AS
BEGIN
select * from APInvoice a where a.RefNbr in (select RefNbr from #APInvoices)
END
and following fragment of C# code:
var par = new SqlParameter("APInvoices", dt);
par.SqlDbType = SqlDbType.Structured;
par.TypeName = "dbo.string_list_tblType";
par.UdtTypeName = "dbo.string_list_tblType";
par.ParameterName = "APInvoices";
PXSPParameter p1 = new PXSPInParameter("#APInvoices", PXDbType.Udt, par);
var pars = new List<PXSPParameter> { p1};
var results = PXDatabase.Execute(sqlCommand, pars.ToArray());
but when I execute my C# code I'm receiving error message:
UdtTypeName property must be set for UDT parameters
When I debugged with reflector class PXSqlDatabaseProvider, method
public override object[] Execute(string procedureName, params PXSPParameter[] pars)
I noticed that
using (new PXLongOperation.PXUntouchedScope(Thread.CurrentThread))
{
command.ExecuteNonQuery();
}
command.Parameters.Items has my method parameters, but item which is related to Udt type is null. I need to know how to pass user defined table type. Has anybody tried this approach?
Unfortunately UDT parameters are not supported in Acumatica's PXDatabase.Execute(..) method and there is no way to pass one to a stored procedure using the built-in functionality of the platform.
Besides, when writing data-retrieval procedures like the one in your example, you should acknowledge that BQL-based data-retrieval facilities do a lot of work to match company masks, filter out records marked as DeletedDatabaseRecord and apply some other internal logic. If you chose to fetch data with plain select wrapped into a stored procedure you bypass all this functionality. Hardly is this something that you want to achieve.
If you absolutely want to use a stored procedure to get some records from the database but don't want the above side-effect, one option is to create an auxiliary table in the DB and select records into it using a procedure. Then in the application you add a DAC mapped to this new table and use it to get data from the table by means of PXSelect or similar thing.
Coming back to your particular example of fetching some ARInvoices by the list of their numbers, you could try using dynamic BQL composition to achieve something like this with Acumatica data access facilities.