Multiple unique columns in sharepoint - javascript

I'm creating a new form in SharePoint with the following fields:
Name
Phone
Email
But, I need that every column in the list is unique, it can't be any row with the same information.
I have an idea how to do this with javascipt, but don't know how to access to do a query in sharepoint to see if there is the same information.
If someone could help me with any solution would be great.
Thanks

I need that every column in the list is unique,
Are you saying that only one row in the list can have a certain email address? If so, just set "Enforce unique values:" for that column to "Yes". (Repeat for each column.)

If you want a column value like Email to be unique you can use the "Enforce Unique values" from the columns settings like shown below.
However if you want multiple columns to be unique like a composite unique key you will have override the presaveaction in the page to do a check before inserting the record. you can get more details of the presave action in the below link.
https://sharepoint.stackexchange.com/questions/91854/what-is-the-difference-between-presaveaction-and-presaveitem-on-sharepoint-l
https://social.technet.microsoft.com/wiki/contents/articles/31330.sharepoint-using-presaveaction-function-on-custom-list-forms.aspx

Related

Need to fill Dropdown field by selecting a value from another dropdown

I'm looking for a logic, where there is a dropdown which has some set of pre-loaded addresses(Street, city, country, state, ZIPCode). The country and state must be dropdown fields.
Now, on selecting one pre-loaded address, it should autofill the country and state.
For example, if the address: Street1, CityNAme, CountryName, StateName, ZIPCOde is selected from the drop down, it should search the CountryName, StateName from Country and State dropdowns and autofill accordingly.
Is it possible to write the code in javascript? I need to include this logic in my SharePoint2013 application.
Please let me know if the requirement is unclear.
Any help is appreciated!
Yes,we could achieve this with JS.
I don’t know the structure of your data, the data source and you didn’t specify the fields that need to be filled in automatically, so I can only give you some ideas.
Firstly,you need to make sure which column values can determine a unique object.
Secondly,Write these columns on the page, you can choose to hard code the values in them, or you can choose to get them from the data source.
Thirdly,When the object can be uniquely determined, you can filter out the object from the data source and automatically populate the value on the page through js/jQuery.

How get id of html elements when it generates dynamically?

I create design for image, checkbox and drop-down list.. the image will create dynamically according to number of row..
My question is how can validate which checkbox was checked and which drop down option was selected because all of its have same id and name
First of all welcome to stackoverflow :D
If all of you checkboxes have the same ID it won't work. You said you create them dynamically then try to give them an special identifier like "myid"+i wehreas i being the number of the element (increase it after instantiating the element).
Then your IDs will look like:
myid0
myid1
myid2
...
with all the objects having a different ID it won't be a problem for you to check which checkbox was selected :)

Add dynamic column to table in smart-table [angularjs]

I needed a little help over here on adding dynamic columns to table and I'm using smart-table project https://lorenzofox3.github.io/smart-table-website/
Please look at plunker
https://plnkr.co/edit/uTDa6hfwdgGtGWkYqL7S?p=preview
Click on add new column, it will update the table header, but I can't update the td element because I haven't created or binded any td element for new column.
Need help on two things.
1) Any number of new columns might come in future from server dynamically, so I can't bind any element statically in html like I did right now.
2) This is a little long one(I want to create a only one header as MV and in colspan I want current and next) and How do I accomplish that one ? If I divide like that, how do I go frame the data ?
Additional Note on Question 1: I have tried dynamically showing the data in table. please look at line 27 in index.html. But again, If I go with this approach, the values get binded to different different columns since, data's are framed dynamically on controller. To be simple, there is no guarantee that data will be in in this order.
(SNo, companyName, companyFullName, MarketValueCurrent, MarketValueNext, QuarterCurrent, QuarterNext)
companyName might come first or at last. If I go by dynamic looping using ng-repeat, it binds MarketValueNext in first column, then companyName, etc in whichever the order the data is coming.
Thanks in advance.

How to save data from dynamically generated textboxes?

I have a page to edit the 'utilization' rate of each employee, based on their designations. So the page has all the designations listed as , next to which a textbox, for the user to fill in the utilization rate. Scenario is that the user will not save each designation's utilization rate immediately after filling it. User will keep going till he fills the last item and then hit the submit button to save. Now, in php I can get all the values from the Request Array. But, how will I know which designations these values belong to? So, what i have as a solution is to name the textboxes with the designation_ids as suffix. May be like;
utilTextbox_1, utilTextbox_2, utilTextbox_3 etc...
Then when the form is submitted;
Check each Request Array element to see if its name starts with 'utilTextbox'
If Yes, split it using '_' to get the designation_id
Update the db table with the value of the text box
Check the next Array Element.....and so on...
is this the correct method or is there a better way of doing this?
You can have array as names in html forms. So something like utilTextbox[1], utilTextbox[2], utilTextbox[3] will work perfectly fine. In php you will get an array in $_REQUEST and you need not to convert in an array because it is already an array.

Populate tabular report (multiple records) with particular values

I have a tabular report that allows the user to enter a reference number (text item) as well as a comment textarea item.
The report can vary in amount of records displayed, but for this example, let's say I have 10 records in the report.
What I am after is to create two new fields identifying both comment and reference no field - let the user type info in these two fields and then have a "Populate All" button that will go through each record in the report and assign the reference number value and comment value to each of the 10 records.
It's not completely clear what you're trying to do here. Do you have a regular HTML form laid out in a table, and then the last two table cells on each row have an input/text area element in them? If so, I would think the easiest way to go about it would be to assign a common class to the input elements in each column, such as 'refno' and 'comment' then have some code like this in the 'PopulateAll' button onclick event:
$(".refno").each(function() {this.value = $($("#refglobal").value)});
This assumes your field for adding the reference number to all has an id of refglobal and that you're using jQuery (though other libraries will allow similar syntax, and coding it out longhand wouldn't be too much effort in this case).

Categories

Resources