RE: Pre populate NewForm.aspx fields with values

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ok I managed to prepopulate using javascript. for a particular field you have
to browse to the page and get the crazy id for the <input> that is generated.

use that to reference the field.

I know of no other way atm.

I actually used this to generate an autonumber in a sharepoint list, this
has also been another lingering issue for some people.

Basically what i did:
-created an ID field in the list
-use XSL to get the ID of the last item in the list. Add 1 to it.
-Use javascript to pre-populate the sharepoint:formfield with the next ID,
and to disable the field from editing... Walla, a hacked autonumber :)

"cm" wrote:

I'm also curious if there is a solution to this.

Seems so far there is now way to set the value of a <Sharepoint:Formfield>
Item.

I've tried the Value attribute, the FieldValue attribute, and a few others.
All produce 'error rendering'.

Also doesnt seem javascript cannot be used on these pages.

"Vanessa" wrote:

Were you able to get an answer to this? I'm trying to basically prepopulate
the new form based on other fields in other lists and I'm having issuse
finding posts on how to do that in WSS2

"Hofmann, Frank" wrote:

Hi,

in WSSv2 the pre population of fields in a NewForm.aspx was done by a client
based JavaScript. Here is an example:
http://sharepointstudio.blogspot.com/2006/05/pre-populate-listfields-on-sharepoint.html

Is there a better way doing this with WSSv3? At least in SharePoint Designer
it is possible to define (query based) parameters for custom list forms. I
was able to display the value of a query string parameter using a easy
<xsl:value-of select="$Parameter"/> syntax.

And I even was able to display a preselected value of a connected lookup
field of the list. The following line displays the 3rd value of a lookup
field "customer" in a task list.

<SharePoint:FormField runat="server" id="ff10{$Pos}" ControlMode="Display"
FieldName="Customer"
__designer:bind="{ddwrt:DataBind('i',concat('ff10',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Customer')}"
ItemId="3"/>

But when I change the "ControlMode" parameter to "Edit" the "ItemId" is not
used to pre populate the lookup field with the 3rd value. And if I set the
"ControlMode" to "Display" in a NewForm.aspx the correct value of the lookup
field is displayed but not saved in a new record.

Is there a possibility to accomplish this task with some build in functions?
Or do I still need a fancy client based java script?

Thanks

Frank


.



Relevant Pages

  • Re: Why IE 7 shrinks Javascript code?
    ... releae) takes my javascript and shrinks all the items being displayed, ... Use a list element to display list items - if I visit your site with ... JavaScript disabled, I see absolutely nothing. ... There are thousands of examples of dynamic lists, ...
    (comp.lang.javascript)
  • Re: Securing Link/URL Display
    ... Build a web part that emits a JavaScript array of the currently logged-in ... SharePoint University http://www.sharepointu.com ... > What about the lists themselves? ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Difference lists
    ... Petronius wrote on 08 aug 2007 in comp.lang.javascript: ... in Javascript? ... Google helps you to find an explanation (try e.g. "difference lists ... 'Haec vulnera pro libertate publica excepi; ...
    (comp.lang.javascript)
  • Re: with only one
    ... hidden variables carefully set to get the desired action depending on ... There are several lists, all with one or more options..I need to select ONE item from ALL the lists and go with that. ... The javascript associated with the onchangeor onclick() stuff does indeed patch in a value to a hidden variable anyway. ...
    (comp.lang.javascript)
  • Re: Lookup Evils
    ... no problems in sorting by the lookup field when it uses a value list. ... different from the value you want to display. ... Keep in mind that combos and listboxes work fine with text ... provide pick lists but you will be responsible for making the same changes ...
    (microsoft.public.access.tablesdbdesign)