Updating data for xml form structure?

I have a scenario that I can’t find an API method for under form or dataprocessor.
There is a form, in a layout, with dataprocessor, where first the form structure from xml is being loaded:

myForm = formContainer.attachForm();	// def view
myFormDP = new dataProcessor(myFormDP);
myForm.loadStruct(myFormXML + new Date().getTime(), myFormLoadCallBack);

Then, in the callback (myFormLoadCallback), I want to load data into the form - only if there is a value assigned to a variable - before continuing to other operations.

function myFormLoadCallBack( {
	// if emailRef exists in URL, load data
	if (thisEmailRef != "") {
	 myForm.load(myFormDP+"&method=loadData&emailRef="+thisEmailRef,loadDataCallBack);
	}
	<snip>
}

It is working, but I’m wondering if there’s a better method to use to accomplish this. I want to always use the xml for the base structure, updating data only when necessary.

Also, unexpected was getting the ids field on the form post as “null”.

myForm.save();

Is there a way to extract the value of the “ids” form field sent on a save, so that I could send it to the myForm.load? That way I could return the xml as

<data>
<12345_affiliate>01</12345_affiliate>
<snip>

instead of:
<data>
<affiliate>01</affiliate>
<snip>

Would that work? Any ideas for me?

As for IDS parameter, form attempts to get id value from the url, but it recognise only direct “id=some” inclusion. You can specify the id directly by using

myForm.load(myFormDP+"&method=loadData&emailRef="+thisEmailRef,function(){ myForm.formId = "myvalue"; });

Awesome info Stanislav. Thank you so much.

Now that I understand how dhtmlx was looking for the value, I knew exactly what to do.

We don’t ever pass an “id” field, or integer values that are keys to our database for security reasons, always using uuids that are never called “id”.

So, no problem to assign a random number, just for dhtmlx to use. Works beautifully!

Here’s what I ended up doing, in case anyone else needs to figure this out:

function myFormLoadCallBack( {
   // if emailRef exists in URL, load data
   if (thisEmailRef != "") {
      // assign random number to form id for dhtmlx
       myForm.formId = Math.floor(Math.random()*50000);

      /* !Important! pass the random formId generated in the load string as id=xxx
       *  so that dhtmlx knows what it is (avoid null_ prefix on form post)
       */
       myForm.load(myFormDP+"&method=loadData&emailRef=" + thisEmailRef + "&id=" + myForm.formId, loadDataCallBack);
   }
   <snip>
}