Access: get the result from a request in a field of table - database

I have a table with fields, I would like that the last field be the result of a request with the parameters of the others fields, it is possible ? I use Access...
To make simple,I would like to know if it is possible to have a request in the field value with parameters which are subject, date_value and date_observ from this table to get information in others table ?

Related

how to insert a lookup field value into salesforce via a rest api when it's not a __c field?

NOTE: there are a million stackoverflow answers explaining inserting into lookup fields that talk about __c fields. They are NOT duplicates of this question.
so I'm trying to insert a value into a lookup field using the rest api.
If the field name looks like blah__c - it's easy - I just insert a {key, value} into blah__r. I do that all over the place.
but in this case my field is called PlanId. Trying to insert into PlanId__r just says no such field. How do I do it for a lookup field that does not end in __c?
You're talking about the insert/upsert by external id trick, right? Because vanilla lookup is absolutely the same, just chuck the 15/18-char id in. blah__c = '001...', PlanId = '003...'
For standard lookup field (without __c) most of the time the relation will be same thing minus the "Id" part. So try Plan = {'UniqueKey__c', '123'} or whatever is your equivalent.
(shameless plug) check my answer https://salesforce.stackexchange.com/a/274696/799, look at how that insert of Asset references Contact and Product2 even though the actual fields are ContactId, Product2Id.
https://salesforce.stackexchange.com/a/23507/799 might be helpful too. Or just use Workbench etc to describe your object.
There are few standard objects where upsert by external id won't work. You might have hard time adding Tasks to Accounts for example because that WhatId field is a mutant, lookup to many tables. Was few years since I tried that though so maybe something changed.

How to generate an activation link in an email via a stored procedure

I want a way to validate emails in order to not choke up our queue. The goal is that when a user is finished with their account setup, the email needs to be validated. My idea is to create a stored procedure that will send an email to the one the user put with a link or something to verify that the email has been sent and opened.
What I am confused with is how to generate this link.
In one of my tables that stores users, I added a column named 'isActive' with type BIT and set to 0. The goal is for the email to have a link where once clicked, will flip the 'isActive' column from 0 to 1, this will verify if the email was reached properly.
I expect that when the user is done entering his info, the stored procedure will send an email to verify that the email is correct by clicking on an activation link.
Based on the comment clarification above, I'm thinking you would want to set one column to a GUID (or add a new column). These links will provide some details about how and why to do this, but the short version is that you can guarantee that the join key is not guessable and is always unique. Set a column to have a default GUID value via UNIQUEIDENTIFIER DEFAULT NEWID() and it will create a new ID with every new row that you can use in other sections of your code.
http://www.sqlservertutorial.net/sql-server-basics/sql-server-guid/
https://www.sqlshack.com/understanding-the-guid-data-type-in-sql-server/

GeneralDetailReportQuery key field

We use GeneralDetailReportQuery to get customer "transactions" from QuickBooks desktop and save them to a mssql table. Query is called passing the From/To Date filter params to get changes only. We try to get report changes each day and keep our table in sync with QB data. TranId, customer ListId and TranType seem to be those fields which can uniquely identify each record returned by Report query. Problem starts to happen when users change one of those key fields, customer ListId for example.
It must have been a change of a customer in a transaction... ?
Anyway, how to keep data in sync, does report have some kind of primary key field, which is not changed and can be use to track changes ?
Thanks,
Slava

Order data using values stored in another table

I've been using cakephp for a while, but have not learned all the ins and outs yet so I may be missing something simple. Or the problem may lie with my database structure. Either way, if anyone has any idea of what I'm doing wrong, please share.
Is there a way to order the data returned by cakephp's find using values stored in another table?
I am creating custom form fields on a per category basis, so when I choose a particular category to post in, custom fields will be added to my form. I have 3 tables: Posts, Fields, and Answers. The Posts table stores the basic static information for the post, such as id, category_id, title, and description. The Fields table stores the custom field data, such as category_id, field_label, field size, etc. The Answers table stores the values that are entered for particular fields, such as post_id, field_id, value.
I am trying to display the posts for a particular category, and create html table headers on the fly, using select fields, set by a column toggle in the fields table, and also select the answers associated with that particular field and post.
I am able to select all the data I want, and paginate everything just fine, but what I can't seem to figure out is how to order the data using one of the dynamic column values. For example, if I have year, make, and model as 3 custom fields, I would like to click the year column to sort my results by the year values, and if I click the make column, I would like to sort my results by the make values, etc.
I know how to order the results by a particular field inside the posts table, such as id or title, but is it possible to order using the custom fields? Am I setting up the database and/or something else wrong, and if not is there are particular cakephp method or sql command that I need to use in order to sort by the custom fields? I'm not really well versed in complex sql commands.
Thanks.
I'd suggest you pass the field name and sort direction in the URL (GET param). So when you have your table header link, form it so that it links to a URL as so:
http://somesite.com/pages/index/sort:customfield1/dir:asc
Then when you're grabbing the data from the db in your find() query, include the named parameters as the order parameter that can be sent to find.
You'll need to determine a default sorting column and direction. Maybe have that be selectable with a boolean field in the schema -- if there are no parameters sent to the action above, pull the field from your other table that has default set to true in the record.
To clarify: when a user visits a given action, first you'll pull the custom fields from the other table. Then using those fields (either the default as mentioned above, or the named params passed in the URL) form the query for the actual data, using the order parameter.

Is using multiple tables an advisable solution to dealing with user defined fields?

I am looking at a problem which would involve users uploading lists of records with various field structures into an application. The 2nd part of this would be to also allow the users to specify fields to capture information.
This is a step beyond anything ive done up to this point where i would have designed a static RDMS structure myself. In some respects all records will be treated the same so there will be some common fields required for each. Almost all queries will be run on these common fields.
My first thought would be to dynamically generate a new table for each import and another for each data capture field spec.Then have a master table with a guid for every record in the application along with the common fields and then fields that specify the name of the table the data was imported to and name of table with the data capture fields.
Further information (metadata?) about the fields in the dynamically generated tables could be stored in xml or in a 'property' table.
This would mean as users log into the application i would be dynamically choosing which table of data to presented to the user, and there would be a large number of tables in the database if it was say not only multiuser but then multitennant.
My question is are there other methods to solving this kind of varaible field issue, im i going down an unadvised path here?
I believe that EAV would require me to have a table defining the fields for each import / data capture spec and then another table with the import - field - values data and that seems impracticle.
I hate storing XML in the database, but this is a perfect example of when it makes sense. Store the user imports in XML initially. As your data schema matures, you can later decide which tables to persist for your larger clients. When the users pick which fields they want to query, that's when you come back and build a solid schema.
What kind is each field? Could the type of field be different for each record?
I am working on a program now that does this sorta and the way we handle it is basically a record table which points to a recordfield table. the recordfield table contains all of the fields along with the field name of the actual field in the database(the column name). We then have a recorddata table which is where all the data goes for each record. We also store a record_id telling it which record it is holding.
This is how we do it where if each column for the record is the same type, then we don't need to add new columns to the table, and if it has more fields or fields of a different type, then we add fields as appropriate to the data table.
I think this is what you are talking about.. correct me if I'm wrong.
I think that one additional table for each type of user defined field for the table that the user can add the fields to is a good way to go.
Say you load your records into user_records(id), that table would have an id column which is a foreign key in the user defined fields tables.
user defined string fields would go in user_records_string(id, name), where id is a foreign key to user_records(id), and name is a string, or a foreign key to a list of user defined string fields.
Searching on them requires joining them in to the base table, probably with a sub-select to filter down to one field based on the user meta-data, so that the right field can be added to the query.
To simulate the user creating multiple tables, you can have a foreign key in the user_records table that points at a table list, and filter on that when querying for a single table.
This would allow your schema to be static while allowing the user to arbitrarily add fields and tables.

Resources