DynaPDF.SetFieldExpValue
------------------------

Changes the choice values of a combo or list box, or to change the state and export value of check box.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [4.0](newinversion40.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.SetFieldExpValue"; PDF; Field; ValIndex; Value; ExpValue; Selected ) 

**MBS**( **"DynaPDF.SetFieldExpValue";** /\* Changes the choice values of a combo or list box, or to change the state and export value of check box. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Field**; /\* The field index or field name.e.g. "FirstName" \*/   
**$ValIndex**; /\* The value index or -1.e.g. -1 \*/   
**$Value**; /\* The new value.e.g. "Hello" \*/   
**$ExpValue**; /\* The export value.e.g. "World" \*/   
**$Selected**) /\* Whether to select the value? \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Field | The field index or field name. | "FirstName" |
| ValIndex | The value index or -1. | -1 |
| Value | The new value. | "Hello" |
| ExpValue | The export value. | "World" |
| Selected | Whether to select the value? |  |

### Result

Returns OK or error.

### Description

Changes the choice values of a combo or list box, or to change the state and export value of check box.   
In the latter case, the parameter ValIndex will be ignored. If the field handle refers to a radio button, ValIndex represents the index into the Kids array of the radio button.  
To determine how many values are defined in a field call the function [DynaPDF.GetFieldExpValCount](DynaPDFGetFieldExpValCount.md) or [DynaPDF.GetField](DynaPDFGetField.md).  
The parameter Value is ignored if the field is a check box or radio button. However, the parameter ExpValue is required for these field types.  
  
If you don't need to change the value or export value then use the function [DynaPDF.SetFieldExpValueEx](DynaPDFSetFieldExpValueEx.md) instead.  
If the field is either a combo box or list box, the parameter ExpValue is optional and can be empty. If the parameter Value is set to an empty string, the choice value will be deleted. Note that all choice values in a combo or list box must be unique. DynaPDF checks whether another choice value with the new name does already exist. If this is the case then the function will fail.  
Combo boxes which have the field flag ffEdit set accept a value that was directly typed into the field in a viewer. Such a value may or may not exist the list of choice values. In any case, a special handling is required for this case because the value must be set as the field's value independent of whether it is already included in the list of choice value.  
To achieve this, set the parameter ValIndex to PDF\_MAX\_INT (2147483647) or any index greater than the number of choice values in the field. The parameter Value can also be set to NULL or to an empty string to delete the field's value. If the string is set then it becomes the new field value but it is not added to the list of choice values if not included.  
Note that the above handling is only valid for combo boxes which have the ffEdit field flag set.  
To enumerate the choice values of a combo box, list box or radio button use the function [DynaPDF.GetFieldExpValueEx](DynaPDFGetFieldExpValueEx.md).  
See also [SetFieldExpValue](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetFieldExpValue.shtml) function in DynaPDF manual.

### See also

- [DynaPDF.CreateComboBox](DynaPDFCreateComboBox.md)
- [DynaPDF.GetField](DynaPDFGetField.md)
- [DynaPDF.GetFieldExpValCount](DynaPDFGetFieldExpValCount.md)
- [DynaPDF.GetFieldExpValue](DynaPDFGetFieldExpValue.md)
- [DynaPDF.GetFieldExpValueEx](DynaPDFGetFieldExpValueEx.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetFieldMapName](DynaPDFSetFieldMapName.md)
- [DynaPDF.SetFieldTextColor](DynaPDFSetFieldTextColor.md)
- [DynaPDF.SetFillColorValue](DynaPDFSetFillColorValue.md)
- [DynaPDF.SetTextFieldValue](DynaPDFSetTextFieldValue.md)

### Example Databases

- [DynaPDF/Fill Form Fields](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Fill%20Form%20Fields.shtml#1ScriptAnchor_)

### Blog Entries

- [Unlocking the Power of PDFs in FileMaker with DynaPDF and the MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2024-09-16/Unlocking_the_Power_of_PDFs_in/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 5th March 2021

  
[DynaPDF.SetFieldDate](DynaPDFSetFieldDate.md) - [DynaPDF.SetFieldExpValueEx](DynaPDFSetFieldExpValueEx.md)

[HTML Version](DynaPDFSetFieldExpValue.shtml)