Hi David Gonzalez,
Thanks for reaching out to Microsoft Q&A.
Observed Issues:
Dynamic Date Expression: When using the dynamic expression 'formatDateTime(adddays(utcnow(),-2), 'yyyy-MM-dd')', it results in an error saying the field is a 'String' but the expected type is 'object'.
Manual Date Works: Manually entering a static date works fine, but the goal is to use a dynamic date to support incremental loads.
Error Explanation
The error in the screenshot ('ErrorCode=InvalidTemplate, ErrorMessage=The function 'json' parameter is not valid...') indicates that ADF is not able to parse the dynamic date string correctly. It seems that the query builder expects the date in a specific format or as an object type, and the dynamic expression is being interpreted as a string.
Probable approach:
- Remove Trailing Spaces: Ensure there are no trailing spaces in your dynamic expression. You can adjust your expression to:
- formatDateTime(adddays(utcnow(),-2), 'yyyy-MM-dd')
- Convert Date to Object Type: Since the error suggests that it expects an object, try wrapping the result in a conversion function that outputs the correct type:
- json(formatDateTime(adddays(utcnow(),-2), 'yyyy-MM-dd'))
- Check ServiceNow API Compatibility: Ensure the API is receiving the date in a format that it supports. Some APIs may require more specific formatting or handling for date fields.
If direct conversion doesn't work, another approach could involve breaking the filter logic into multiple steps or using a Lookup activity to resolve the dynamic date first and then passing it to the filter query.
Try these adjustments in your query and check if the connector processes the dynamic date without errors. If the issue persists, please share more details, and we can dive deeper into alternative approaches or configuration fixes.
Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.