Save field value programmatically

HI!

Help me, please, how to programmatically change the value of the field and save it by Save button?

This code works:

$doc.set("Field", $tempValue)
$doc.save()

But I don’t want to explicitly save the document at this moment, it should make the user save the page after form editing. Without $doc.save() the value is not saved.

You could check https://www.xwiki.org/xwiki/bin/view/FAQ/How%20can%20I%20create%20a%20new%20page%20based%20on%20a%20form and adapt it.

  1. AWM form;

  2. The Software field with Database List type;

  3. Custom display code:

     {{velocity}}
    
     ##Show checkboxes, softID field and Submit button in edit mode:
     #if($context.action == 'edit') 
    
       {{livetable id="hdwLookUpSoftware" classname="SoftwareInventory.Code.SoftwareInventoryClass" columns="softID,softType,softName,softVersion,softLicense" 
       selectedColumn="softID" defaultOrder="asc" tagCloud="false" extraParams=""/}}
    
       {{addCheckboxColumnToLivetable livetable="hdwLookUpSoftware" column="softID" buttonId="sftCheckboxService" serviceDocument="ServiceDocument" /}}
    
       {{html}}
         <div class="buttonwrapper">
           <a href="" id="sftCheckboxService" class="button">Save Linked Software</a>
         </div>
       {{/html}}
    
       #set ($tempVar=$datetool.get('HH:mm:ss'))
       $doc.set("hdwSoftware", $tempVar)
       $doc.save()
    
     ##Hide checkboxes, softID field and Submit button
     #else 
    
       {{livetable id="hdwLookUpSoftware" classname="SoftwareInventory.Code.SoftwareInventoryClass" columns="softType,softName,softVersion,softLicense" 
       selectedColumn="softType" defaultOrder="asc" tagCloud="false" extraParams=""/}}
    
     #end
    
     {{/velocity}}
    
  4. In edit mode I set checkboxes in LiveTable manually;

  5. Click the Save Linked Software button;

  6. On the ServiceDocument page, I analyze the passed parameters using $request.getParameterValues ​​("cbData");

  7. I transfer these parameters as a value to the Software field in the AWM form;

  8. When i click the Save button, I hope that the data will be saved, but not.

Also I think that pp. 6, 7 can be optimized, but I do not know how

BTW:

In Sandbox document this script

{{velocity}}
$doc
{{/velocity}}

returns

Sandbox.Glossary

And all other docs have a Glossary suffix.
Is it correct behavior?

Thanks.