User Picker to field values - google-app-maker

Sorry if this is too basic for this site, but app maker help directed me here. I am creating a data entry screen that includes basic info for a user - name, email, phone, etc. I am using the user picker to select the individual from our Directory. How do I pass all of the needed Directory field values of the selected user to my insert record screen. I am checking the valueisRecord box on the user picker, but can't figure out how to assign the selected user's info to the form's value fields. Thanks for the help.

Ok, your last comment makes sense. But please, to avoid going back and forth, I encourage you to formultae your question properly by including all the information that could be required. Now, moving on to your problem...
The reason you are getting that error is because you are binding the UserPicker widget value to the datasource email field. Remember, the UserPicker value is an object, not a string.
To fix your problem, remove the binding of the value from the UserPicker. Then for the onValueChange change event of the UserPicker please add the following:
var fullName = newValue.FullName;
var email = newValue.PrimaryEmail;
widget.datasource.item.Name = fullName
widget.datasource.item.email = email;
That way, you don't assing an object to the email field but instead a plain string.

Related

How to ensure that the username that is auto-populated does not get replaced by another one in InfoPath

I have an approve and reject form having three views. In the first view i.e the requester's view I auto-populate the requester name by using "GetUserProfileByName". Now I also want to auto populate the name of the user who approves the form in a different view (but this view also has the requester's name)- so I was wondering if I actually use "GetUserProfileByName" again won't it change the first name too (i.e the requester's name). I don't have other accounts to test it out.
Can someone please provide a workaround to this problem
So basically I want this to happen:- For example when John enters the form his name should be auto populated in the requester's name field. And once this form is send to Michelle who approves it - the approver's name field should have been autopopulated with Michelle's name.
How can I avoid overwriting of data.
Thank you for helping
Add fields to the form data source to store the data returned from GetUserProfileByName service. Do not use default values for the values in these fields. Instead, I generally use form load rules for this - run the query, and then, if the requester field is blank, set the field to the user's name from the datasource.
When the approved view is submitted, you can take a similar approach with the approver name field - if it is blank, set it.

InfoPath - How can I read a people picker field and query AD to load additional fields related to the person in the field.

How can I read a people picker field and query AD to load additional fields related to the person in the field. Example: Employee Name; load information want to load email address, phone number. the InfoPath form is being used with Nintex Workflow and SharePoint 2010.
I have searched and have not been able to find answer.
Thanks
D
Unfortunately I don't have enough reputation points yet to leave a comment, but your question really doesn't provide enough detail. So any answer provided is going to be based on assumptions. You don't even clarify what version of InfoPath you're using.
That said, a good place to start is to create a data connection to receive data. You'll need to select the web service option and will then need to enter in the web server address. The address will probably be in the following format:
http://yourservernamehere/_vti_bin/userprofileservice.asmx?wsdl
Replace yourservernamehere with the address of your SharePoint server. Then, you'll need to select GetUserProfileByName as the operation you need. Just keep on clicking next and then finish to complete the connection.
You will then have to view the data source within InfoPath to see what fields are available and map the ones you want to the fields you want prepopulated on your form.
All this is based on my own assumptions, so I can't guarantee it will work in your scenario. Happy to assist if you still need help and are able to provide more details.
To autocomplete you can use your e-mail or phone number fields, with a new action rule. This is due to people picker fields not allowing any action rules applied to them.
The web service option mentioned in another answer unfortunately no longer works in SharePoint Online. Please use a data connection the hidden User Information List located on the stem of your SharePoint site instead.
Condition:
Use the condition DisplayName is not blank by using "Select a field or group..." in advanced view and selecting your people pickers DisplayName field
Actions:
Set a field's value
Field: User Information List data connection queryFields DisplayName of people picker
Value: your forms DisplayName of people picker
Query using a data connection: User Information List data connection
Set a field's value
Field: your forms email or phone number field
Value: data fields > Work_email / Work_phone of your data connection

Is there documentation for non-dynamically adding a 'many' to a 'one' in a 'one-to-many' relationship?

I have a Customer who has several PhoneNumbers.
The user creates a new Customer via a form, and I want him to be able to specify a single PhoneNumber.
Symfony's documentation tells me how to do this if the user were creating a PhoneNumber and had to also specify a Customer (link). It also tells me how to solve my problem using some Javascript, as described by the Cookbook's recipe for dynamically adding entities (link).
What I'm missing is the part of the documentation where it simply describes a non-dynamic form that lets you add a single entity upon submission. So, the user fills out the customer's details, puts a phone number, and everything works out.
I suppose I could make a separate form, give it a PhoneNumberType, and then upon submission, call $customer->addPhoneNumber($phoneNumber). But it seems like there should be a way to handle it through the relationships alone & in a single form.
Coming back to this question, I realize the answer is simple. In my controller,
// CustomerController.php
$customer = new Customer();
$phoneNumber = new PhoneNumber();
$customer->addPhoneNumber($phoneNumber);
Now when I build my form, I'll have a single blank PhoneNumber associated with the new Customer, and everything will persist as expected.

Extracting unique messageID from sql in gridview asp.net c#

I have a message database that stores the private messages from users to users. I have a column called MessageID, which is a unique number. In my application, I have a message inbox (using gridview) page that shows the user who messaged you, the subject, and the create date. Next to it I have a button you can click to view the message. I am wondering if there is some way I can extract the MessageID of the message so I can use a SELECT FROM with a WHERE query to get the body of the message.
Maybe I could store the MessageID on the .aspx page somewhere but keep it hidden?
Nevermind, I got a working solution! I just added a column for the MessageID on the gridview and I turned the visibility of it to be false so the user can't see it. But this way the MessageID is there and I can use it as a query parameter

ASP.NET Site architecture issue

Due to the nature of the way the website I am working on was designed I have an issue I now must resolve.
I will try to write this question as language-independent but the site is done in ASP.Net with C#.
Overview
The structure of our site looks like this for any given "object":
ASPX Page
Multiple UserControls (ascx pages)
Textboxes, Comboboxes, Labels,
Buttons, etc.
What this means is, if we have a User page and that page might have 3 UserControls. One for User Information (Name, email, etc.), one for Address (City, State, Zip, etc.) and one for Regional Settings (Time zone, language, etc.)
All of these fields on the 3 UserControls are all stored in the same table in the database.
Now, we are using DataBinding and EntityFrameworks to fill in the data and this means that when we save an object, we are actually calling save 3 times (1 per UserControl).
(Language-Agnostic: We don't actually
assign values like User.Name =
"Bob", it is handled by a Framework)
Because the UserControl only knows about the fields it contains, when the Databinding saves it "thinks" the other fields are now blank. (i.e. Address control saves and now "Email" and "Name" are null values). To "fix" this there is a method called "MapOldToNew" which goes out and grabs the old record and fills in the values on the New object that is about to be saved. This is generic, which means we don't have a method on the Address Usercontrol that says "go get the Name and Email fields and fill them in", instead it loops through all the properties of the Entity(object) and if a value is NULL on the New object but NOT NULL on the Old object (the one currently in the database about to be overwritten) it will make the New value equal to the Old value.
The Problem
Dates. We allow NULL dates in our database.
If a User fills in "Birthday" and saves, they now have a Birthday value in the field in the database.
If they go back and clear out the Birthday field on the web page and save, the MapOldToNew method grabs the old record, sees that Birthday is not null there and is Null on the New object about to be saved, it will override the New value (NULL) with the Old value ('7/23/1981' for example).
Solutions?
Rework our system to not use
UserControls but instead have all
controls on the same Page, thereby
reducing the number of times we need
to Save and not requiring
MapOldToNew. For now, let's
assume this is an impossible
solution (even though it is the one
I feel like should be done for
plenty of reasons).
Store all
dates as Strings and do conversion
on Load and Save. (Strings don't
have the same problem because once a
string has been modified it is now
an empty string, and not NULL)
Do not allow NULL dates in the
database and always store
DateTime.MinValue and do not
display it On Load.
Those are the ideas I have come up with off the top of my head. For arguments sake, let's assume #1 is not possible (because I have a feel management won't like the time it will take to accomplish).
How would you "fix" this?
Another Explanation
Here is the problem broken down more.
User Record has 2 fields. Name and Birthdate.
Assume that there is 1 ASPX Page with 2 UserControls (ascx).
UserControl1 has a single DatePicker DataBound to "BirthDate".
UserControl2 has a single TextBox DataBound to "Name".
When UserControl1 calls Update on the ObjectContext the User object it sends looks like this:
{ Name = NULL, BirthDate = 8/13/1980 }
MapOldToNew looks at the Database Record and sees that Name should be "Bob" so it fills the value in and the record saves.
UserControl2 calls Update now and the User object looks like this:
{ Name = "John", BirthDate = NULL }
MapOldToNew sees that BirthDate is NULL so it overwrites it with 8/13/1980 from the database and the record saves and the database has the correct values.
Now assume the user goes back in and deletes the BirthDate value. When UserControl2 calls MapOldToNew, it sees that BirthDate is NULL (which the user wants) and overwrites it from the Database.
If it DIDN'T overwrite it from the database, it would always save it as NULL and the user would never be able to set the BirthDate.
I would refactor MapOldToNew to understand nullable types. Im assuming you have a nullable date (for ex. datetime? or Nullable and if so - do not make the assumption of overwriting if null.
Also in the future consider MVC or for WebForms consider Dynamic Data because of the mapping of types to models.
http://aspnet.codeplex.com/wikipage?title=Dynamic%20Data

Resources