SaaS CMS has officially launched! Learn more now.

Unique Identifier using XForms

Vote:
 

Hello All,

Is there anyway by default to have a unique ID on every row when an individual form is filled in?

Will need this for audit purposes.

Many Thanks.

Marc.

#58419
Apr 24, 2012 17:03
Vote:
 

Hi,

Not sure what you mean. But every form posting is a row in the database and every row has an identifier of some kind.

#58422
Apr 24, 2012 18:43
Vote:
 

Hi Johan,

Basically in the database table within EPiServer, which displays all the results, we need the auto generated field to appear in the results, infront of the other fields.

#58436
Apr 25, 2012 13:39
Vote:
 

Do you mean in the "Form Data" tab in edit mode?

#58438
Apr 25, 2012 14:00
Vote:
 

Hi Johan,

Yep, thats the one. So when its exported into excel, there will always be the unique ID displaying next to each row.

#58439
Apr 25, 2012 14:08
Vote:
 

Maybe there is an event you can listen to and add an id to each row in the exported file.

But I would listen to an event when the form is posted and then add a guid to the posting. You can add columns on the fly to a posting, it doesn't need to be in the xform definition.

#58453
Apr 25, 2012 14:24
Vote:
 

Roughly (not compiled) :

protected void Application_Start(Object sender, EventArgs e)
{
XFormControl.ControlSetup += new EventHandler(XForm_ControlSetup);
}

 

public void XForm_ControlSetup(object sender, EventArgs e)
{
XFormControl control = (XFormControl)sender;

control.BeforeSubmitPostedData += new SaveFormDataEventHandler(XForm_BeforeSubmitPostedData);
}

public void XForm_BeforeSubmitPostedData(object sender, SaveFormDataEventArgs e)

{
XFormControl control = (XFormControl)sender;

e.FormData.SetValue("MyKey", new Guid().ToString());

}

#58456
Apr 25, 2012 15:55
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.