+ Start a Discussion
learnSFlearnSF 

How to get user info in html conponent of home page?

I create html component on home page where someoen put text in textbox and hit go buttton,case will be created.

 

Issue: It says invalid session Id. (So I used login method nad gave my username and password) but when it create case ,it define my name for owner of case. I need owner who is logged in.

 

How to get logged in user info in html home component.

 

Here is my code.

 

<script src="/soap/ajax/14.0/connection.js"></script> <script language="JavaScript" type="text/javascript"> function submitSearchForm(){ var searchField = document.getElementById('advsearchfield'); var result = sforce.connection.login("myname@xxx.com.test", "password"); var newCase = new sforce.SObject("Case"); newCase.Description =searchField.value; newCase.Status="Closed"; newCase.Origin="Hot Button"; newCase.Subject="General Inquiry"; result = sforce.connection.create([newCase]);if (result[0].getBoolean("success")) {alert("new account created with id " + result[0].id);} else {alert("failed to create account " + result[0]);}} </script> <form name="advsrch" method="post" onsubmit="return submitSearchForm();"><input class="searchTextBox" id="advsearchfield" maxlength="80" size="18" name="sbstr">&nbsp;<input class="btn" value=" Go! " type="submit"></form>

 

 

any suggestion?

 

Thanks

stevejonesstevejones

hmmm.. Nice question but sorry I don't have any idea for this... Anyway i'll be also waiting for the solution from other members.

 

sfdcfoxsfdcfox
It appears that this is not possible using the API Toolkit, as it is not considered an SControl and therefore does not support merge fields. As such, you can not directly use the toolkit. Best I can tell, you'd have to extract the session from document.cookie, and use sforce.connection.init to properly initialize the toolkit. Alternatively, one could use the Flex toolkit or a Java applet, but this seems a bit much for a simple form. Finally, one could use some rudimentary HTML skills to find the field names and page URLs that are involved in the creation of a new record.
learnSFlearnSF

Finaly I solved this problem.

 

I created html type s-control with ajax toolkit to retrive user info.

 

In html componenet I put this html type s-control in iframe and it worked.