Hi @Shri-6058 ,
I understand EmpNumber
stand for the id of employees (including general employees and managers), while ManagerId
is the "EmpNumber" of managers. Now you want to query rows those "EmpNumber" in fact stand for a manager.
In my opinion, it's not able to achieve it in one step. First we have to get all manager records and remove all duplicated elements.
For example, we get all managerid: /items?$select= ManagerId
, the result will be an array.
Remove duplicates using JS code:
response.d.results.reduce((accumulator, current) => accumulator.find(item => item.ManagerId === current.ManagerId) ? accumulator : accumulator.push(current) && accumulator, []);
After that, we can generate a caml query with In
element to get rows that their "EmpNumber" fall in the above array.
let optionValues = filteredArray.map(e => `<Value Type='Text'>${e.ManagerId}</Value>`).join('');
var caml = `<View><Query><Where><In><FieldRef Name='EmpNumber' /><Values>${optionValues}</Values></In></Where></Query></View>`;
var data = {
"query": {
"__metadata": { "type": "SP.CamlQuery" },
"ViewXml": caml
}
};
You can check the full demo code here:
Note that my test columns are 'single line text' fields.
Best Regards,
Baker Kong
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.