Hi I have created an onClick javascript button "Complete Job" on the custom object "Job".
I have used the below coding:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
sforce.connection.sessionId = '{!$Api.Session_ID}';
function getBaseURL() {
var url = location.href; // entire url including querystring - also:
window.location.href;
var baseURL = url.substring(0, url.indexOf('/', 14));
if (baseURL.indexOf('http://localhost') != -1) {
// Base Url for localhost
var url = location.href; // window.location.href;
var pathname = location.pathname; // window.location.pathname;
var index1 = url.indexOf(pathname);
var index2 = url.indexOf("/", index1 + 1);
var baseLocalUrl = url.substr(0, index2);
return baseLocalUrl + "/";
} else {
// Root Url for domain name
return baseURL + "/";
}
}
var JobstatusCheck = sforce.connection.query("SELECT sked__Job_Status__c FROM sked__Job__c WHERE Id = '{!sked__Job__c.Id}' AND sked__Job_Status__c < > 'Complete' ");
var records = JobstatusCheck.getArray("records");
//alert(records);
if (records.length > 0) {
alert(records);
var base = getBaseURL();
alert(base);
var url = base + encodeURI('/flow/Complete_Job_and_JA?JobId= {!sked__Job__c.Id
} & retURL = /{!sked__Job__c.Id}');
alert(url);
window.open(url);
alert(window.open(url));
//window.location.href;
} else {
alert('Job status is already Complete.Please check with your system
administrator
for more information on this ');
}
When I click on the "Complete Job" button a new tab should open where in there will be a button for "Complete Job"
When I click this button the Job Status should change to "Complete".
This functionality is working perfectly in my sandbox org but it is not working in my production org .
I tried to put an "alert(url);" after the declaration of the variable "url"
The url which I am getting should be a tab containing the "Finish job " button .
This is working perfectly in my sandbox org but it is not working in my production org.
Please guide me how to solve this problem
Here Custom Object is "Job"--sked__Job__c and its picklist field is "Job Status"--sked__Job_Status__c