Can we add cust apparam rule has a condition in sync rule , like I have created a custom apparam for days of site history to be synced , code value = 7, I need to put this constraint in the sync for a view table (site history view), which will sync only the site history of the task before 7 days from current date.
so I need to add in the xml to compare the created dttm of task and related task for same place within 7 days .
Can anyone suggest the solution for this.
Thanks
Muthujayashree R
Page 1 / 1
Hi @Muthujayashree,
You can use IN operator in the data constraint for your XML query. With this approach, you can use any sql query to retrieve data.
Ex -
<constraint> <left_operand>c_site_history_view.primary_key</left_operand> <operator>IN</operator> <right_operand>(select primary_key from c_site_history_view where created_dttm >= (select param_value from cust_app_params where param_name = ‘YOUR_CUST_PARAM’))</right_operand> </constraint>
Note - Better to optimize the result as much as possible. Otherwise, it may impact to the performance in both server & mobile.
Hi Anjula ,
Thanks for the Reply .
I am facing an issue in xml code while giving the SQL query in right operands .
please find the screen shot of the error
can u please tell me what is the issue .
Thanks
Muthujayashree R
Hi Anjula ,
Thanks for the Reply .
I am facing an issue in xml code while giving the SQL query in right operands .
please find the screen shot of the error
can u please tell me what is the issue .
Thanks
Muthujayashree R
Hi @Muthujayashree,
Here, I can see some issues in the sql query. Could you please try to execute the sql query to make sure it returns correct result or not.
You can refer below example for this.
<hierarchy_select max_rows="5"> <primary_table>request_event</primary_table> <attrs> <attr>request_event.sequence</attr> <attr>request_event.event_dttm</attr> </attrs> <from> <table>request_event</table> </from> <where> <data_constraint> <constraint> <left_operand>request_event.sequence</left_operand> <operator>IN</operator> <right_operand>(select sequence from request_event where event_dttm >= (getdate()-cast((select param_value from metrix_app_params where param_name = 'NOTIFICATION_TIME_LIMIT') as int)))</right_operand> </constraint> </data_constraint> </where> </hierarchy_select>
Note - I have used max_rows="5" to reduce the number of records only for testing purposes. Also, I used baseline app param(NOTIFICATION_TIME_LIMIT), because I don’t have any custom app param to try out. In your case, you can replace cust_app_params instead.
I assumed you are using SQL server database. If not, Feel free to change the sql query as you wish.