Is it legal/okay to create a row with ID '0' and AFTER that set auto increment of that ID column to (1, 1)?
Why do I ask this?
I have a table Products with columns ID and Name. I want to show all Products inside my application in a ComboBox. Users can select a product but the default entry should not be 'Product 1' but something like '(Nothing selected)'. Is it okay to create a 'dummy row' with 'ID = 0' and Name = '(Nothing selected)' in database so the application will automatically display it as default selected item?
I think the better solution is to programmatically add a please select option and validate against it, assuming you don't really want users to have this selected? I guess in theory what you've proposed should be OK though? You'd have to be careful retrieving the values in order of their Id though, if you ordered them by name you'd have to ensure you pulled Id = 0 first then ordered the rest which feels like more work then programmatically adding the option where needed to me.
If your users can have nothing selected then programmatically add the nothing selected option and handle saving no value if it is selected. Otherwise you're saving data that represents no data really which could be deemed a waste of memory.
Related
I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!
before asking i wanna to show my tables and their relationships(created with ms access 2007)
here is the schema :
https://plus.google.com/photos/113802558354450440804/albums/5988059068393888337/5988059068667446962?banner=pwa&pid=5988059068667446962&oid=113802558354450440804
in this case, i create 3 combo boxes in VB2010 :
cbx_major(binded to MAJOR table)|major_id as the VALUE MEMBER, major_name as DISPLAY MEMBER
cbx_student(binded to STUDENT table)|student_id as the VALUE MEMBER, student_name as DISPLAY MEMBER
cbx_course( this is the question )
And here is the scenario :
first, i must choose what major is at cbx_major
second, the cbx_student will instruct the STUDENT table to select the student_name where major is equal to the selected value of cbx_major and set that query result as the DISPLAY MEMBER of cbx_student(this is done succesfuly without writing any code )
(this is the question)then the last, i want to set the cbx_course to display the course_name where student_id is equal to cbx_student.
i have done a lot of effort to do this :
i opened the combobox tasks menu and choose the student_course table and trying to create the query but it results "the schema returned by the new query differs from the base query"
i created the query in access by Joinning the table STUDENT_COURSE and COURSE using INNER JOIN then i bind the cbx_course to that query but it results wrong display.
i opened the xsd file then i create the query there but results wrong result
all those effort does not work.
i want to solve this case without writing code but using a technique such setting the taskbar menu, is it possible ? any idea? thanks so much for the attention
I use three fields in Sqlserver Datavbase tables, for prevent delete records permanently by user:
IsDelete (bit)
DeletedDate (DateTime)
DeletedUserID (bigint)
I wish to set third field (DeletedUserID) by UI by some thing like this:
this.ExamdbDataSet.AcceptChanges();
DataRowView row = (DataRowView)this.BindingSource.Current;
row.BeginEdit();
row["DeletedUserID"] = User.User.Current.ID;
row.EndEdit();
this.ExamdbDataSet.AcceptChanges();
row.Delete();
and other two fields ,'IsDeleted' field and 'DeletedDate' are set automatically in table's 'After Delete Trigger'.
then commit changes to database with desire command successfuly with this code:
this.TableAdapterManager.UpdateAll(this.ExamdbDataSet);
but problem is , the 'DeletedUserID' is null in database.
and Question is : How to set 'DeletedUserID' field value by true way in UI?
I don't think it is a good way to do that. You have sliced a simple logic to separate parts, each being done in a different part of the application (UI, Trigger, ...). You set value of some field, and then DELETE the whole record! Don't expect anything else that the current situation.
You would better set all fields in UI (i.e. no trigger in this case), and change the query that loads data. For example,
Select * from table1 where IsDeleted=0
You didn't tell us anything about whether your use ASP.Net or WinForms. Give us more info.
To all salesforce experts i need some assistance. I have my contacts and a custom object named programs. I created a junction object using to master detail relationships with contacts and programs. I want to avoid relating the same contact to the same program. I tried triggers but I couldn't create the testing part to use it outside sandbox.
I went back to the basics and created a Unique text field. I tried to use default value but EVERYTHING i write in that crap is wrong -_-. I tried Contact__r.Email & "-" & Program__r.Name but to no avail.
I tried workflow rules with a field update but my field update NEVER runs.(Yes I did activate the workflow rule) and I didn't know what to write in my rule's code.
The workflow firing condition could be simply a formula that says true. Alternatively use "every time record is inserted". It also depends whether your master-details are set once and that's it or they will be "reparentable" (option introduced in Summer '12 I think). Maybe post a screenshot / text description of your firing condition? Also - is your unique field set to "case sensitive"?
As for the formula to populate the unique field - something like Contact__c + ' ' + Program__c (or whatever the API names of your fields are) should be OK. Don't use Contact__r.Email etc as these don't have to be unique...
You'll have to somehow fill in the uniqueness criteria for all existing records (maybe that's why you claimed it doesn't work?). If you can use Apex for data fixes - something like this should get you started.
List<Junction__c> junctions = [SELECT Contact__c, Program__c
FROM Junction__c
WHERE Unique_Text_Field__c = null
LIMIT 10000];
for(Junction__c j : junctions){
String key = String.valueOf(j.Contact__c).left(15) + ' ' + String.valueOf(j.Program__c).left(15);
j.Unique_Text_Field__c = key;
}
update junctions;
Keep rerunning it until it starts to show 0 rows processed. The Ids are cut down to 15 chars because in Apex you'd usually see full 18-char Id but workflows use 15-char versions.
I have been asked to look into FileMaker for creating a pretty simple database app. The application will handle contact information, some information about events hosted by the organization and - and this is where I'm currently struggling - RSVP information that link the contacts and events, as well as stores some data about payment.
What I would like to use is some kind of form where the user gets to search for a contact (any combo of first/last name) and an event (any combo of name/date), select each from two respective lists (where all other information is displayed as well, to distinguish the results), add some extra information and hit submit.
The closest I've gotten so far is a form where the user can enter a ContactId and EventId manually, which means that he/she first has to go to another view, search for the records, and copy/paste the id numbers.
Is there really no way to get closer to my vision using FileMaker?
Would a better option be to build a new, custom app using for example C# and MsSQL?
If so, how do I sell this to my contractor? As this would in that case be my first commercial application, there is obviously a "safety factor" that speaks in favor of an established product. And then we haven't even mentioned that the cost would probably increase, as developing a new app from scratch would take much longer time.
Note: I have no previous experience with FileMaker. I've tried to read the documentation, but I haven't been able to find any tutorials that take me closer to my specific needs. I'm fairly experienced in MsSQL, so I do know this and that about database management in general - just not in FileMaker.
There are loads of ways to do it. This is a quick way to get it to work.
Let's say you have two tables like this:
Contacts Events
-------- --------
ContactID EventID
FirstName EventDate
LastName EventDetails
Create a new link table between them that also stores the extra RSVP information you want.
RSVP
--------
fk_ContactID
fk_EventID
PaymentInfo
Create a FORM table
FORM
--------
ContactSearch
cContactMatch = Calculation, If(isEmpty(ContactSearch) ; "ALL" ; ContactSearch)
EventSearch
cEventMatch = Calculation, If(isEmpty(EventSearch) ; "ALL" ; EventSearch)
Add the following fields to the Contacts and Events tables:
Contacts
--------
cMatchField = Calculation, Stored, (FirstName + NEWLINE + LastName + NEWLINE + ALL + NEWLINE + Firstname LastName)
Events
--------
cMatchField = Calculation, Stored, (EventDate + NEWLINE + EventDetails + NEWLINE + ALL)
This means that the cMatchField for Contacts will look something like this:
John
Smith
John Smith
ALL
In the relationship diagram, connect the tables like this:
FORM
--------
cContactMatch = CONTACTS/cMatchText
cEventMatch = EVENTS/cMatchText
Create a layout called FORM based on the FORM table.
Add the fields ContactSearch and EventSearch to the layout. Add the PaymentInfo field.
Add two PORTALS to the layout, one for the Contacts table, one for the Events.
By default you should see all the records in each of these portals.
Write a script, or use a script trigger, that refreshes the layout whenever one of those search fields is Exited/Modified. This should refresh the portals and show you the related records you're interested in.
Add a button to each row in the portals and call a script that sets a global variable to that portal rows ID.
For example:
Script: Set Selected Contact ID
Set Variable ($$ContactID ; Contacts::ContactID)
Script Set Selected Event ID
Set Variable ($$EventID ; Events::EventID)
Add another button to the layout and a new script.
Script: Create RSVP
# Check that a contact and event have been selected
If(isEmpty($$ContactID) or isEmpty($$EventID)
Exit Script
End If
# Get the payment info that has been entered
Set Variable ($PaymentInfo ; FORM::PaymentInfo)
# Create the RSVP Link record
Go To Layout(RSVP)
Create New Record
Set Field(fk_ContactID ; $$ContactID)
Set Field(fk_EventID ; $$EventID)
Set Field(PaymentInfo ; $PaymentInfo)
Commit Records
Go to Layout (Original Layout)
# Clear the search fields
Set Field(PaymentInfo; "")
Set Field(ContactSearch; "")
Set Field(EventSearch; "")
Set Variable($$ContactID; "")
Set Variable($$EventID; "")
Commit Records
Refresh Screen
Phew.
And you should be back, ready to search for Contacts, Events, and "Submit" the form to create more RSVPs.
FileMaker is fun, eh?