Lookup to picture name of picture library in sharepoint 2010 - sharepoint-2010

I have a picture library and I want to lookup to the name of picture in another generic list. I've tried:
lookupField.LookupField = "Name";
Then when I create a new item of this generic list, the picture lookup column show the list name of picture correctly, but after saving item this column is changed to blank.
Am I doing anything wrong here? Do I have to use other internal field name instead of "Name"?
Pleaze help...

OK, I found another solution. because I can not lookup to default name of picture library, so I create a hidden text field for picture library. This hidden field will get value of name in ItemUpdated event (no need ItemAdded because when I upload a new pic, it also called ItemUpdated <-- don't know why...)
public override void ItemUpdated(SPItemEventProperties properties) {
properties.ListItem["HiddenImageName"] = properties.ListItem["Name"].ToString();
properties.ListItem.Update();
}
Generic list will look up to this hidden field instead of default name field of Picture library

Related

Script to extract and assign values from a nested JS object

I presently have a nested JS object of the format:
var oNames = {
Adobe:{LastUpdate:'03/09/2022',Website:'adobe.com',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'',SecondaryCC:'',PrimaryBank:'',SecondaryBank:'',SQ1:'First girlfriend',SA1:'Denise',SQ2:'Grade school attended',SA2:'OLPH',Notes1:'',Notes2:''},
Amazon:{LastUpdate:'10/06/2020',Website:'amazon.com',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'Discover',SecondaryCC:'Capital One',PrimaryBank:'',SecondaryBank:'',SQ1:'',SA1:'',SQ2:'',SA2:'',Notes1:'',Notes2:''},
AmericanGiant:{LastUpdate:'01/25/2022',Website:'american-giant.com',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'',SecondaryCC:'',PrimaryBank:'',SecondaryBank:'',SQ1:'',SA1:'',SQ2:'',SA2:'',Notes1:'Best Hoodies Made in the USA',Notes2:''},
Asus:{LastUpdate:'11/05/2022',Website:'https://www.asus.com/us/',UserID:'jdoe#gmail.com',PWD:'1234567',PrimaryCC:'',SecondaryCC:'',PrimaryBank:'',SecondaryBank:'',SQ1:'',SA1:'',SQ2:'',SA2:'',Notes1:'Goto for MB & Laptop Computers',Notes2:''},
.
.
.
]
Can someone please provide me with a sample script that loops through the object above to obtain the values for the properties in the object above associated with each name using the variable, cName, that derives its value from a selection made by an end user from a drop-down box form field that resides on a PDF form. In short, the value provided by the variable 'cName' will be one to match any one of the name values in the object, i.e., Adobe, Amazon, AmericanGiant, Asus in which event the remaining fields residing on the PDF form will be populated with those property values associated with the name selected. Hope this explanation is clear. Unfortunately, I am not as familiar working with object pairs as I am with arrays and as such am stuck creating a script that works with a nested object as provided above. Thank you ahead of time.
for(j=0;j<15;j++){
f=getField("inf."+j);
cName = oVendors[event.value][j];
}
"inf."+j denotes 1 of 15 PDF form fields to be populated from the values in the object associated
with the name in the object equal to 'cName', the name selected in the combo box that resides on the PDF form.
Upon further study of the JS object and its methods, the following script is
required to extract names stored inside a JS data object in a hidden text field
used to populate a drop-down box on the PDF form as follows:
dsFld =getField("dataSrc");// call getField method used to obtain the stored
data value in the hidden text field that resides on the PDF form
oVendors = JSON.parse(dsFld.value);// parse the JSON string to convert to a JS
object to complete tasks to follow
f = getField("cbNames");// call the getField method to get the
drop-down combo box field or later use
aNames=new Array();// create the temp array
for(var key in oVendors){// script to populate the temp array from names
taken from/stored in oVendors data object
aNames.push(key);
}
aNames.sort();// sort the names alphabetically in the temp array
f.setItems(aNames);// assign names from the array to the drop-down
Combo Box field on the PDF form
f.insertItemAt("Add or lookup and select a name");// Insert text item at
the topmost item provided in the drop-down combo box list
dsFld.value=JSON.stringify(oVendors);// convert JS obj back to a JSON
string value stored in the hidden text field
Sorry for the initial ambiguous post and any inconvenience to the forum.

database list contains wrong objects

Goal:
To create a database with documentation about drivers. The idea is to create both vendor and protocol entries, and to link them, as follows: Inside the protocol creation form, I would like to select which vendor supports this protocol.
Approach:
I used the Create your own! button to create the following 2 Applications:
Vendors
Protocols
Inside the protocol creation page I've put a Database List field. With the following properties:
Name = vendors
Display type = select
Multiple select = false
hibernate query : I left this field blank.
xwiki class name = VendorsCode.VendorsClass
ID field name = doc.name
value field name : I left this field blank.
Problem:
To my surprise this works, but not entirely. When I open the form to add a protocol, in the vendor dropdown list there are now not only vendors but also a couple of other objects such as : "Blog.BlogIntroduction". Obviously I don't want that in the list. Why is it in there, and how can I get it out ?
I tried to add the value doc.name in the value field name box as well. But that actually only makes it worse. Now the list only contains "Blog.BlogIntroduction".
Notice that this is a clean fresh installation of xwiki. There's nothing special in this database.
What is going on here?
What you see is the default value for the select item in the Database List, as it is stored in the template page for "Protocol" objects.
A new Database List is initialized to show a list of blog posts, by having a default value of Blog.BlogPostClass for the "XWiki Class Name". (You can try this by creating a new Database List field in step 2 and open the edit view that field; just delete it after you are done.) For a fresh installed wiki there are two blog posts: the "blog page template" in Blog.BlogPageTemplate and the blog intro post in Blog.BlogIntroduction. Exactly these two items are shown initially.
After you fill in the value of your class in the "XWiki Class name" field, XWiki has a chance to find the actual list of possible values.
However it keeps the selected "default value" from the first attempt around (even though it makes no sense).
This looks like a bug to me, at least from a user experience.
How to fix it
First Step: The reason why your list only contains the bogus "default value" might be that the class you have given does not exist.
From what I see in the screenshot the class name looks ok for me, but then this field is not tolerant to any kind of typos, even something like a space before the class name. If the name does not fit exactly, it gives a (nearly) empty list.
If you cannot get it working with the class name and want to go the HQL route instead, use for the HQL field
, BaseObject as obj where doc.fullName = obj.name
and obj.className = 'VendorCode.VendorClass'
and doc.fullName != 'VendorCode.VendorTemplate'
and doc.fullName both as id and value field. This has the additional benefit that the template vendor is not available in the drop down, only the "real" objects.
After you managed to fix the name of the class, you should see a list of all vendor objects (including the VendorCode.VendorTemplate, unless you went the HQL route), and the remaining bogus default value. Now you can continue to the next step:
Second Step: if you managed to fix the class name, you will see your vendors in the drop down beside the default value; now it is time to get rid of the bogus default value. For this go to the template object of the application; e.g.
follow the "Edit Application" link on the start page of the "Protocol" application
then look at the box with the three checkboxes below the field definitions; the uppermost of the checkboxes says "Update class template"
this part contains a link to something called "ProtocolTemplate".
click the link and you end up at the template page
on the template page, click on edit and choose some other value from the drop down of vendors, and then click save.
The "BlogSomething" value should be gone now from the selection of vendors.
Optional step (not answering the quesion, but might be of interest anyway)
If you prefer to have no value at all preselected in the template, you need a few more steps:
in the application edit, edit the field and choose "multiple select" and display type "checkbox"
go to "next step" in the editor, then back to field edit with "previous step"
uncheck the checkbox beside the selected vendor entry, then open the field editor and set "display type" back to checkbox and unset the "multiple select" checkbox.
go the "next step" and "finish"
Afterwards if you create a new "protocol" entry, this is has an empty "vendor" preselected.

Add link to contacts in outlook Appointment Module Form using custom fields

I'm a long date leecher of this site... this is the first time I'm not able to find a response (Google didn't help too).
Well, what I am trying to do is to add an active link to a contact to a custom field in an Appointment Module Form.
I can put the address I want in the appointment custom fields using this code (vb.net):
Dim extendedPropertyDefinition = New ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "MyField", MapiPropertyType.String)
item.SetExtendedProperty(extendedPropertyDefinition, "address#iwant.com")
I am able to view MyField using a custom field in my Appointment Module Form.
Setting "To" field to the value (in custom field properties) i can transform the e-mail into the corresponding contact name (obviously if it exists in contacts list).
Here comes the trouble:
I would like to add a link to contact card when clicking the contact name.
I don't really know if it is even possible...
Thank you very much for any help... "It is not possible" will be an appreciated response too.

Textbox databinding to 2 properties

I have a form that saves to an order data table. A few of the fields in the form are linked to a table that contains customer names and address details. The shippername field in my order data table is a combobox - you select the name and the corresponding address information for that name is displayed in textboxes that belong to the address, city and phone number fields for my order datatable. For that, I am using the databinding property of the combobox control for that field, and using the Text property for the textboxes (binding to the source table, which I call shipperdata.) When I run the form, it displays the information I want.
The problem: when I save the form, the names of the shippers are saved fine. However, the other fields related to the shipper name are not. I realized that the binding property would not let me bind the contents of the textbox to my order datatable.
I went into the designer and thought I'd try an experiment, thinking that if the combobox can bind to a source and bind the text to the order datatable, I should be able to do that with a textbox. Right? Apparently not so much. Here's what I tried:
'Shipper1address1TextBox
'
Me.Shipper1address1TextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ShippersBindingSource, "SHIPPERADDRESS1", True))
Me.Shipper1address1TextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.OrdersBindingSource, "shipper1address1", True))
Me.Shipper1address1TextBox.Location = New System.Drawing.Point(188, 429)
Me.Shipper1address1TextBox.Name = "Shipper1address1TextBox"
Me.Shipper1address1TextBox.Size = New System.Drawing.Size(200, 20)
Me.Shipper1address1TextBox.TabIndex = 32
I got an error saying that I couldn't bind 2 properties.
The funny part: the form is actually 'details' so I decided to drag a datagridview next to what I already had set up to see how it looked. In detail view, you'd think the data was being saved correctly to the orders data table. But, when I looked at the table in gridview, the values for the address and phone, etc were not written there. Then i reminded myself that it's only bound to the shipper data table.
My question: how can I save the corresponding address and phone information to the order table while still binding to the source so it displays? If I make the binding property to the orders data table, that's great...except now it doesn't display address information. Is there a method to accomplish this with a textbox? I'm also guessing at this point that messing with the designer is probably not a great idea. Maybe an alternative? It just seems odd that the value contained in a textbox from a data table isn't saved.
Thanks for having a look.
You can only add one databinding to each text box.
You are adding two in your code.......
Me.Shipper1address1TextBox.DataBindings.Add
ArronG.

get list name in sharepoint 2010

how to get current used list name. my scnerio is: i have a list said config. i have create one column say "test" whose datatype is "Managed Metadata". now after add this column.now when i edit this item and click on icon near to "test" column one dialog is open which is webtaggig.aspx something like that.
now, i had open my custom control in this page. when page opened , my control is loaded.
now on my custom control page load i want to get the list name programatically.
can any one suggest me how can i do this?
Have a look at the SPContext object. You would need something like SPContext.Current.List.Title to get the name or title of the current list.