You need to sign in to do that
Don't have an account?
SFDC n12
user detail page redirection through link
Hi,
I am having the following below javascript in a vf page which is displaying the users in a table
I have added a link to the user where on click of the link it should redirect me to the corresponding user record, i have added the link using <a href > tag,
Need help on user record redirection
My Java script
<apex:page showheader="true" sidebar="true">
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="../../soap/ajax/29.0/connection.js"
type="text/javascript"></script>
<script>
function getUserInfo()
{
try
{
var userInfoById = {};
var output='<font size="2" color="blue"><table><tr><th>User </th><th>Date </th><th>Open Tasks </th><th>Open Opportunity </th><th>Open Threat</th></tr></font>';
//logic to fetch the frozen users list
var result = sforce.connection.query("Select Id,LastModifiedDate ,FirstName, LastName from User where Id in(Select userId From UserLogin WHERE IsFrozen = TRUE) AND IsActive=true");
var it = new sforce.QueryResultIterator(result);
while(it.hasNext())
{
var record = it.next();
//logic to fetch the open Task count
var taskcount = sforce.connection.query("Select id from Task where Status!='completed' AND ownerid='"+record.Id+"'");
var taskresultset =taskcount.getArray("records");
var taskresultcount;
if(taskresultset!=null)
{
taskresultcount=taskresultset.length;
}
else
{
taskresultcount ='';
}
//logic to fetch the open opportunity count
var opportunitycount = sforce.connection.query("SELECT ID FROM Opportunity WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' AND ownerid='"+record.Id+"'");
var oppresultset =opportunitycount.getArray("records");
var oppresultcount;
if(oppresultset!=null)
{
oppresultcount=oppresultset.length;
}
else
{
oppresultcount='';
}
//logic to fetch the open Threat count
var threatcount = sforce.connection.query("Select id from Threat__c where Status__c !='Closed Won' AND Status__c !='Closed Lost' AND ownerid='"+record.Id+"'");
var threatresultset =threatcount.getArray("records");
var threatresultcount;
if(threatresultset!=null)
{
threatresultcount=threatresultset.length;
}
else
{
threatresultcount='';
}
var name=record.FirstName + ' ' + record.LastName;
var date = new Date(record.LastModifiedDate);
console.log(date.toISOString().slice(0,10));
output+='<tr><td><a href="#">'+name+'</a></td><td>'+date+'</td><td>'+taskresultcount+'</td><td>'+oppresultcount+'</td><td>'+threatresultcount+'</td><td>';
output+='</td></tr>';
output+='</td></tr>';
}
output+='</table>';
document.getElementById('output').innerHTML=output;
}
catch (e)
{
alert('Exception = ' + e);
}
}
</script>
<apex:sectionHeader title="Frozen State Users:"/>
<div id="output"> </div>
<script>
getUserInfo();
</script>
</apex:page>
Thanks in Advance
I am having the following below javascript in a vf page which is displaying the users in a table
I have added a link to the user where on click of the link it should redirect me to the corresponding user record, i have added the link using <a href > tag,
Need help on user record redirection
My Java script
<apex:page showheader="true" sidebar="true">
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="../../soap/ajax/29.0/connection.js"
type="text/javascript"></script>
<script>
function getUserInfo()
{
try
{
var userInfoById = {};
var output='<font size="2" color="blue"><table><tr><th>User </th><th>Date </th><th>Open Tasks </th><th>Open Opportunity </th><th>Open Threat</th></tr></font>';
//logic to fetch the frozen users list
var result = sforce.connection.query("Select Id,LastModifiedDate ,FirstName, LastName from User where Id in(Select userId From UserLogin WHERE IsFrozen = TRUE) AND IsActive=true");
var it = new sforce.QueryResultIterator(result);
while(it.hasNext())
{
var record = it.next();
//logic to fetch the open Task count
var taskcount = sforce.connection.query("Select id from Task where Status!='completed' AND ownerid='"+record.Id+"'");
var taskresultset =taskcount.getArray("records");
var taskresultcount;
if(taskresultset!=null)
{
taskresultcount=taskresultset.length;
}
else
{
taskresultcount ='';
}
//logic to fetch the open opportunity count
var opportunitycount = sforce.connection.query("SELECT ID FROM Opportunity WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' AND ownerid='"+record.Id+"'");
var oppresultset =opportunitycount.getArray("records");
var oppresultcount;
if(oppresultset!=null)
{
oppresultcount=oppresultset.length;
}
else
{
oppresultcount='';
}
//logic to fetch the open Threat count
var threatcount = sforce.connection.query("Select id from Threat__c where Status__c !='Closed Won' AND Status__c !='Closed Lost' AND ownerid='"+record.Id+"'");
var threatresultset =threatcount.getArray("records");
var threatresultcount;
if(threatresultset!=null)
{
threatresultcount=threatresultset.length;
}
else
{
threatresultcount='';
}
var name=record.FirstName + ' ' + record.LastName;
var date = new Date(record.LastModifiedDate);
console.log(date.toISOString().slice(0,10));
output+='<tr><td><a href="#">'+name+'</a></td><td>'+date+'</td><td>'+taskresultcount+'</td><td>'+oppresultcount+'</td><td>'+threatresultcount+'</td><td>';
output+='</td></tr>';
output+='</td></tr>';
}
output+='</table>';
document.getElementById('output').innerHTML=output;
}
catch (e)
{
alert('Exception = ' + e);
}
}
</script>
<apex:sectionHeader title="Frozen State Users:"/>
<div id="output"> </div>
<script>
getUserInfo();
</script>
</apex:page>
Thanks in Advance
Let us know if it helps.
All Answers
http://www.w3schools.com/js/js_window_location.asp
can you help me with the code pls
output+='<tr><td><a href="#">'+name+'</a></td><td>'+date+'</td><td>'+taskresultcount+'</td><td>'+oppresultcount+'</td><td>'+threatresultcount+'</td><td>';
i am new to javascript
Thanks
Let us know if it helps.