Use Pattern Match Fetch
Initialize
const {data} = usePatternMatchFetch(patternModel, changedValue, path)
Pattern Model
If you required resolve data from direct query. Pattern model should be string query name
65e33f7903
Otherwise if you want to resolve data, corresponding to the data pattern. Pattern model should be array of object like this
[ { "type": "erp", "pattern": null, "query": "65e33f7903", "path": "message.value" }, { "type": "standard", "pattern": "LD-", "query": "DLAD Lead", "path": "data.first_name" }]
Pattern model have mainly three types
- erp
- standard
- standard-list
Required Model fields
{ "type": '', "pattern": '', "query": '', "path": '' }
If you pass keyValuePair with this model, Hook return dropdown array like this
//pattern { "type": "standard-list", "pattern": "LD-", "query": "DLAD Contact", "fields":["*"], "filters": [["reference_name","=","${value}"]], "keyValuePair": {"key": "name", "text": "contact_name"}, "path": "data" }//result [ {key: "CNT-0001", text: 'Gotabaya'}, {key: "CNT-0001", text: 'Mahinda'} ]
When you use standard-list
{ "type": '', "pattern": '', "query": '', "path": '' }
Changed Value Argument
You should pass value what you want to match with this pattern
Path Argument
This argument is not a mandatory argument. If you want a custom path you can change it
Examples
[ { "type": "erp", "pattern": null, "query": "65e33f7903", "path": "message.value" }, { "type": "standard", "pattern": "LD-", "query": "DLAD Lead", "path": "data.first_name" }]
[ { "type": "erp", "pattern": null, "query": "5b2341e02e", "path": "message" }, { "type": "standard-list", "pattern": "LD-", "query": "DLAD Contact", "fields":["*"], "filters": [["reference_name","=","${value}"]], "keyValuePair": {"key": "name", "text": "contact_name"}, "path": "data" }]