IDEA
|
Hi @LouisDECOMBE , yes i did some modifications. and it works in portal enterprise , but you need to update the token every 2 weeks , i will share the modified code. and just replace where you need to change the ID's and portal url copy the below and paste it in xhr js file const estimateBtn = document.getElementById('estimate-btn');
const reportBtn = document.getElementById('report-btn');
const sendHttpRequest = (method, url, data) => {
const promise = new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.responseType = 'json';
if (data) {
xhr.setRequestHeader('Content-Type', 'application/json');
}
xhr.onload = () => {
if (xhr.status >= 400) {
reject(xhr.response);
} else {
resolve(xhr.response);
}
};
xhr.onerror = () => {
reject('Something went wrong!');
};
xhr.send(JSON.stringify(data));
});
return promise;
};
const estimate = () => {
let params = new URLSearchParams(document.location.search.substring(1));
let oid = parseInt(params.get("objectId"));
let token = params.get("token");
console.log(oid);
console.log(token);
sendHttpRequest('GET', 'https://survey123.arcgis.com/api/featureReport/estimateCredits?portalurl=https://geo.********man.com/portal&featureLayerUrl=https://geo.man.com/server/rest/services/Hosted/service_cc2e2ab2544fd4cebdb833ae354/FeatureServer/0&queryParameters={"where": "objectId='+oid+'"}&templateItemId=0f088a**********5a6f48a1f14ee&token='+token).then(responseData => {
console.log(responseData['resultInfo'].cost);
//return responseData['resultInfo'].cost
document.getElementById("estimate_credits").innerHTML = "Estimated credit cost: " + responseData['resultInfo'].cost;
//return x.innerHTML = responseData['resultInfo'].cost;
});
};
const createReport = () => {
let params = new URLSearchParams(document.location.search.substring(1));
let oid = parseInt(params.get("objectId"));
let token = params.get("token");
console.log(oid);
console.log(token);
sendHttpRequest('POST', 'https://survey123.arcgis.com/api/featureReport/createReport/submitJob', {
"portalUrl":'https://geo.man.com/portal',
"utcOffset":'||+04:00',
featureLayerUrl: 'https://ge*****o.mm*******an.com/server/rest/services/Hosted/service_cc2e2a08b4*********fd49*b833ae354/FeatureServer/0',
queryParameters: '{"objectIds":"' + oid + '","orderByFields":"||last_edited_date DESC, objectid ASC"}',
templateItemId: '09f08e66aa6f85********48414ee',
token: token,
surveyItemId: '4204632348a8a*******6adcf4a705',
outputFormat: 'pdf'
})
.then(responseData => {
console.log(responseData);
checkJobStatus(responseData['jobId'], token);
})
.catch(err => {
console.log(err);
});
};
const checkJobStatus = (jobId, token) => {
sendHttpRequest('GET', 'https://survey123.arcgis.com/api/featureReport/jobs/' + jobId + '?token='+token+'&portalUrl=https://geo******.******man.com/portal').then(responseData => {
console.log(responseData);
document.getElementById("generate_report").innerHTML = responseData['jobStatus'];
if (responseData['jobStatus'] == 'esriJobExecuting') {
document.getElementById("generate_report").innerHTML = responseData['jobStatus'];
setTimeout(checkJobStatus(responseData['jobId'], token), 10000);
} else if (responseData['jobStatus'] == 'esriJobSucceeded') {
console.log(responseData['resultInfo'].resultFiles[0].url);
// document.getElementById("generate_report").innerHTML = responseData['resultInfo'].resultFiles[0].url;
document.getElementById("generate_report").innerHTML = "Download Report Here";
document.getElementById("generate_report").href = responseData['resultInfo'].resultFiles[0].url;
}
});
};
reportBtn.addEventListener('click', createReport);
... View more
09-18-2023
02:38 AM
|
0
|
0
|
670
|
IDEA
|
Hi @ZhifangWang Any update about the Enhancement Number: ENH-000142314 Synopsis: Generate Feature Report directly by URL Parameters in Survey123
... View more
02-26-2023
09:23 PM
|
0
|
0
|
818
|
POST
|
I have bulk of points which are not snapped to the polyline and the points are in the end and over the polyline . I need to snap those point with one click if possible any one have a solution ??
... View more
11-19-2019
10:58 AM
|
0
|
1
|
356
|
Online Status |
Offline
|
Date Last Visited |
09-18-2023
11:35 AM
|