function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
learnSFlearnSF 

How to get 15 digit Id from Salesforce database

Hi,
 
I want 15 digit TagDefinationId from slaesforce database.Rightnow it is returning 18 digit.
 
I need to use this Id inside iterator loop with href.
 
Here is my function.
 
Code:
<apex:dataList value="{!accountTags}" var="accountTag" id="theList">
 <apex:outputLink value="/search/TagSearchResults—tIdList={!accountTag.TagDefinitionId}&tagsSearch={!accountTag.Name}&lsc=-10&" id="theLink" title="View records tagged {!accountTag.Name}" rendered="{!showPersonalTag2}" >{!accountTag.Name}</apex:outputLink>
 , 
</apex:dataList>

 

Using 18 digit Id is not giving me correct href link.

Can someone give me Idea to place directly 15 digit Id in visual force outputlink syntext with loop.

I don't want to go to controller nad come back with Id.

-any way to get 15 digit Id from query instead of 18 digit.

-Thanks


 
Best Answer chosen by Admin (Salesforce Developers) 
ESES
I'd rather add an action-metod in the controller or an extension of the page that performs the deletes and updates the page accordingly. But if you really have to use the ajax toolkit for this, try setting the session id before making the delete call by doing something like,

Code:
sforce.connection.sessionId = "{!$Api.Session_ID}"

 

All Answers

ESES
try using the Left function. First 15 digits of an 18 digit ID is essentially the 15 digit ID.

For example:
Code:
{!left(account.id,15)}

 

learnSFlearnSF

Thanks,

It solved my problem.

Basicaly I am trying to write Tag componenet inside Tabbed page layout with same look and feel as original account page have.

Now I am facing another issue.

I want to delete Tag when user click on tag name from visual force custom component while Edit tag.

Here is my code.

Code:
<script src="/soap/ajax/14.0/connection.js" type="text/javascript"></script> 
<script language="JavaScript1.2" src="/js/functions.js"></script> 
<script type="text/javascript" language="JavaScript1.2">
function foo(tag){
alert(tag);
var delResult = sforce.connection.deleteIds([tag]);
  if (delResult[0].getBoolean("success")) {
alert("Tag with id " + result[0].id + " deleted");
} else {
alert("failed to delete Tag " + result[0]);
}
}
</script>
<apex:repeat value="{!accountTags}" var="accountTag" id="theList1">
<span class="tag">
{!accountTag.Name}[
<FONT color="#FF0000" >
<span class="tagRemove" title="Remove tag {!accountTag.Name}" onclick="foo('{!accountTag.Id}');">X</span>
</FONT>]
</span>,
</apex:repeat>

Here I am getting faultCode:'sf:Invalid_session_Id' exception.

Can you point me how to work this script or how I can send this request to contrller and remove the Tag from Salesforce database.

My probllem is I don't know how to send accountTag.Id to controller when user click on that tag so in contrller I cna remove this Tag.

So I place ajax call in component it self so I don't need to call controller and send tag Id to controller.

-Any suggestion?

 

-Thanks,


 

ESES
I'd rather add an action-metod in the controller or an extension of the page that performs the deletes and updates the page accordingly. But if you really have to use the ajax toolkit for this, try setting the session id before making the delete call by doing something like,

Code:
sforce.connection.sessionId = "{!$Api.Session_ID}"

 

This was selected as the best answer
learnSFlearnSF

Thanks ES,

It solved my problem.

I am done with personal tagging component.Let me know if some one wants to use this custom component inside visual force page.