• ChrisMcL
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 50
    Questions
  • 31
    Replies

Hey,

 

In my managed package I have a VF page that uses the AJAX toolkit to invoke some Apex webservice, like so:

 

var x = sforce.apex.execute("myClass", "method", {});

 

Notice that there is no namespace specified. I was hoping that by packaging and installing this into a client org the above script would call the *local* version of myClass.method(). Am I hoping for nothing here? Or is my assumption correct?

 

Thanks!

I am looking for info on how this works, but can't find a white paper. Is it IP specific? machine specific? Can I use the activation link for both my home laptop and my pc at work? etc.
 
James
What's the best practice to find out how my help scontrol was called when the user clicked "Help for this Page" on my custom object screen? I would like to have one help scontrol be a controller and forward the user to our help pages based on what SF page the "help for this page" was clicked. For example, if I was on Accounts detail screen and choose "help for this page" and a custom scontrol was set for the help setting. Somehow the scontrol can "know" what topic is being requested and create a link to forward the user to into our help content. This is particularily important for us and custom objects help. It would also be cool to know if the user had clicked New or Edit as well. Is there any best practice for determining this?
 
James Wikkerink
Cloudbench Applications
Before I use the results in a SOQL single query. How do I check for if the query returned 0 rows? (The size() method is not available in queries where I only expect to get at most one record.

Eg.

Account citizen = [select Id, Name from Account where Name = 'Citizen' limit 1];

if (?citizen is not empty?) {
   
}
I am doing something similar to Person Accounts in my Account trigger.
 
Using the dataloader, I get the above error message. I know it is due to this query being in my account trigger for loop:
 
contact[] contactMatch= [select Id, LastName, MailingStreet from Contact where LastName = :accountNameSearch and mailingStreet = :billingStreetSearch and (AccountId = :a.Id or AccountId = null)  limit 2];
 
This contact query searches for contacts that have the same name and address as of the account(s) that are being added. If I was just referring to the account Id, then I could use a Map and an in clause in my query. However, I also check for matches based on other variables: name and address.
 
My for loop constructs the variables :billingStreetSearch and :accountNameSearch are based off the account fields for each account.
 
To solve this, I will:
  1. I will store the 3 items: account Id's, name and address into 3 maps (unless there is a way to to store 3 items into a single map)
  2. I will use three IN clauses in my contact query
  3. I will create another account for loop to search for matches in the contacts result set.
I have ONE question:
  1. How do I search the contact result set efficiently? eg. for a given account Id, is there a match in my contact list? I don't want to look through a batch of 200+contacts for each account trigger. Can I sync up the two lists somehow? eg. "these contacts are really only to do with this account, don't bother looking at the others in this contact list."

thanks for any ideas!

James

I like the ability of upsert in the data loader to use the external id to find out which record to update. However, for this one-time purpose I don't want it to do an insert if the id's don't match. Is there a setting I can say, "update if you find a match, but do nothing if there is no match"?

I am aware that I could delete out the new records that I didn't want created after the upsert process, I'm just wondering if I can turn off inserts temporarily.

James
Municipal Software
In an effort to not add duplicate contacts, can I export the ID field on contacts (along with the name and address). Then do some external database matching on the name and address, and upsert the data including the ID field? Or do I have to split the data into an update of the contacts I do have an ID for and then insert contacts that don't have an ID?
I think the nature of Apex would not allow this, but apex can't call a scontrol can it? I know an scontrol can trigger or even call an Apex function, but I don't think vice-versa...

James
Municipal Software
Is it possible to schedule a report export as an Excel file? Or have it created on a ftp site?
Has anyone wrote a null replacement apex method for strings? I keep getting the error, attempting to dereference null. Similar in behavior to the formula NULLVALUE(expression, substitute_expression).
 
In this example I am concatenating a contact first and last name together. But the first name is often null. the string then becomes null lastname instead of just last name
When I create my own button to run my scontrol merge fields were getting populated eg {!MUSW__Permit__c.MUSW__Issued-Date__c}. However, when I run the same scontrol via an New button override on the same related list, the merge fields are blank. What's going on? Do merge fields not work when using button overrides? How do they expect us to pass data into these scontols? Thanks for any feedback.
 
James
For example, an scontrol that is run by overridding the New button. Can the scontrol tell what Action button was clicked? eg. some merge field like {!$Action.current}
a Workflow Rule based on the formula:
 
ISCHANGED(LastActivityDate)
 
does not trigger when I complete an activity. The criteria always evaluates to false. Is it because the backend is changing this field?
I have a lookup field. The user can search in the lookup field like normal, but sometimes they don't know the name. Instead, they have an alternate unique value that they can search in the sidebar, but the search lookup can't use it (because it only searches the name field).
 
To solve this, I can create two additional fields, one to hold the alternate search value and the second one is a formula field created as a hyperlink to run an scontrol to go fill in the lookup field using the alternate value. I know this is possible, but this is multi-stepped and requires the user to save and then click the hyperlink formula and then the screen refreshes.
 
Is there a way to do this in edit mode? What options do I have to:
  • give the user something to click on in edit mode? (eg. like a calendar popup)
  • set lookups to search other than the name field?
  • custom buttons available in edit mode?
  • or any other ideas?

I know it is possible to set fields based on this help text of a solution I've found:

In order to have the value of a lookup field pass through in a custom link, make sure to include both components listed above in the custom link. The field name id is usually appended with a "_lkId". Please make sure to verify this within the html code.

For example, an Account Name lookup field in an Opportunity record will need the following string within the custom link in order for the Account Name to be passed on to the new record the custom link is creating:

opp4={!Account_Name}&opp4_lkid={!Account_ID}


Thanks in advance!

James Wikkerink

Municipal Software

I am setting the Task reminder date/time field using a date field and adding the number of dates. How do I convert a date field to date/time?
Code:
Submittal_Received__c +28

Syntax checker on the above formula field says I can't use the date field. Help shows to use the DATEVALUE field for converting date/time field to date, but what can I do to convert a date to date/time?
Just wondering if anyone has a technique to split up formulas and make them exclusive (one does not overwrite the outcome of the other.
 
formula: if picklist is a certain value, lookup a number and multiply it by another number field. In real life, the case statement is hundreds of items long. How could I split up this statement into two for example?
 
I would like to make the multiplication dependent on whether the case statement found a match.
Code:
case(field,
"type1", 30,
"type2", 50,
amountfield) * field2

 
Do i use Ischanged?
Currently, I have a workflow field update formula that looks up a picklist value and assigns a value and adds it to a date. It works for items that have assigned values, but I want the formula not to do anything if no value is assigned (ie. return the value of the field I am updating).
 
To do this right now, i have to get the value, pass it to an IF statement and then the True portion of the statement has to reget the value. Is there a shorter way to re-use the case statement without creating another formula field? See code:
Code:
IF(CASE(MUSW__Type__c,
"Use Permit (major)",50,
"Admin. Permit - Land Use (minor)",20,
0) <> 0, 
CASE(MUSW__Type__c,
"Use Permit (major)",50,
"Admin. Permit - Land Use (minor)",20,
0) + Review_Complete__c,
MUSW__Due_Date__c)

 
 
Thanks for your help.
 
James Wikkerink
Municipal Software
I am looking for a way to assign an owner to some other value, whether it is a user lookup field on a parent or some complex formula. What options do I have? I have noticed that workflow field updates of owner are not flexible enough (no formulas allowed).
I know it is possible to add the number of days to a date field by:
 
Code:
MUSW__Issued_Date__c + 182

 
but it is possible to add the number of months to date? If so, how?
 
Thanks,
James Wikkerink
Municipal Software
On a contact lookup field and clicking the search button (magnifying glass), the lookup screen does not find the contact. However the sidebar search does find it. For example, searching for RYAN DANIEL does not find the contact: RYAN DANIEL J & CYNTHIA A, but is found in the sidebar search.
 
The above contact has RYAN DANIEL J & CYNTHIA A stored completely in the contact last name.
 
What do I do? What logarithm is Salesforce performing to find this? I even tried RYAN DANIEL*. It seems that as soon as I enter a space in the search field, salesforce parses the field in a way that I don't understand.
 
James Wikkerink
Municipal Software
 
What's the best practice to find out how my help scontrol was called when the user clicked "Help for this Page" on my custom object screen? I would like to have one help scontrol be a controller and forward the user to our help pages based on what SF page the "help for this page" was clicked. For example, if I was on Accounts detail screen and choose "help for this page" and a custom scontrol was set for the help setting. Somehow the scontrol can "know" what topic is being requested and create a link to forward the user to into our help content. This is particularily important for us and custom objects help. It would also be cool to know if the user had clicked New or Edit as well. Is there any best practice for determining this?
 
James Wikkerink
Cloudbench Applications
I like the ability of upsert in the data loader to use the external id to find out which record to update. However, for this one-time purpose I don't want it to do an insert if the id's don't match. Is there a setting I can say, "update if you find a match, but do nothing if there is no match"?

I am aware that I could delete out the new records that I didn't want created after the upsert process, I'm just wondering if I can turn off inserts temporarily.

James
Municipal Software
Has anyone wrote a null replacement apex method for strings? I keep getting the error, attempting to dereference null. Similar in behavior to the formula NULLVALUE(expression, substitute_expression).
 
In this example I am concatenating a contact first and last name together. But the first name is often null. the string then becomes null lastname instead of just last name
a Workflow Rule based on the formula:
 
ISCHANGED(LastActivityDate)
 
does not trigger when I complete an activity. The criteria always evaluates to false. Is it because the backend is changing this field?
Just wondering if anyone has a technique to split up formulas and make them exclusive (one does not overwrite the outcome of the other.
 
formula: if picklist is a certain value, lookup a number and multiply it by another number field. In real life, the case statement is hundreds of items long. How could I split up this statement into two for example?
 
I would like to make the multiplication dependent on whether the case statement found a match.
Code:
case(field,
"type1", 30,
"type2", 50,
amountfield) * field2

 
Do i use Ischanged?
I know it is possible to add the number of days to a date field by:
 
Code:
MUSW__Issued_Date__c + 182

 
but it is possible to add the number of months to date? If so, how?
 
Thanks,
James Wikkerink
Municipal Software
On a contact lookup field and clicking the search button (magnifying glass), the lookup screen does not find the contact. However the sidebar search does find it. For example, searching for RYAN DANIEL does not find the contact: RYAN DANIEL J & CYNTHIA A, but is found in the sidebar search.
 
The above contact has RYAN DANIEL J & CYNTHIA A stored completely in the contact last name.
 
What do I do? What logarithm is Salesforce performing to find this? I even tried RYAN DANIEL*. It seems that as soon as I enter a space in the search field, salesforce parses the field in a way that I don't understand.
 
James Wikkerink
Municipal Software
 
Here's my full scontrol code to link a file as an attachment without uploading the file onto Salesforce. It saves SF storage space and upload/download time for large files. Most importantly, it relates documents to the appropriate Salesforce object and viewed instantaneously.
 
To use the code, you need to add your own way of parsing the URL for the parentID (eid) parameter, and base64 encoding (we have these in our common library which we bring in using !INCLUDE). Other than that it's good to go and will attach to any parent having attachments. Create a link that calls the scontrol. Here's a sample link we call Link Attachment:
 
Code:
{!URLFOR( $SControl.MUSW__LinkAttachment  , MUSW__Permit__c.Id, [debug= $User.MUSW__Debug__c, 
stepthrough= $User.MUSW__Step_Through__c ])}
 
The Case Detachifier app on the appExchange gave me the idea for the placeholder attachment. It's seemless to the user, except if the file was moved or removed in the user's network (link is effectively broken). Files added under the Notes & Attachments related list have the word (LINK) after the filename to show it is not stored on Salesforce.
 
We still cannot find a way to customize the Notes and Attachment section to add or overwrite their "Attach File" buttons so it remains as a link on the detail page instead of in the related list. Next step for us is having a tighter integration with a file repository/management with choices of folders, etc.
 
James Wikkerink
Municipal Software
 
Code:
<html>
<head>
 <title>Link Attachment</title>
 <link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet">
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/8.0/connection.js"></script>
    {!INCLUDE($SControl.MUSW__lgmCommon)}
    <script id="clientEventHandlersJS" language="javascript">
    <!--  
var b64 = new lgmBase64();

function setup() {

 lgm.href.getParameters();
 
}
function submit2(fullFileName) {
var fileName = "";
var placeholder = "";
var nameSuffix = " (LINK)";
 
 //get just file name
 if (fullFileName.indexOf('/') > -1)
        fileName = fullFileName.substring(fullFileName.lastIndexOf('/')+1,fullFileName.length);
    else
        fileName = fullFileName.substring(fullFileName.lastIndexOf('\\')+1,fullFileName.length);
 
 //make filename URL friendly
 URLfullFileName = "file:\/\/" + fullFileName.replace(/\\/g,"/");
 
 //confirm if want to link to a local file
 if ((fullFileName.indexOf("C:\\") > -1)  || (fullFileName.indexOf("D:\\") > -1)) {
 
  var x = window.confirm("Are you sure you want to link to a local file that no other users can access—"); 
  if (!x)
   return true;
  else
   nameSuffix = " (LOCAL LINK)";
 }
 
 if (URLfullFileName.indexOf("'") > -1 ) {
  alert("File names or paths containing single quotes (') are not allowed. Please rename file name or path.");
 } else {
 
  placeholder = "<html><head><meta http-equiv='refresh' content='1;url=" + URLfullFileName + "'></head>"+
     "<body><br><center>Opening file <a href='" + URLfullFileName + "'>" + URLfullFileName + "</a> <br>" +
     "Click link if file does not automatically open.</center></body></html>";
  
  var attachmentRecord = new sforce.SObject("Attachment"); 
  attachmentRecord["ParentId"] = lgm.href.param["eid"];
  attachmentRecord["Name"] = fileName + nameSuffix;
  attachmentRecord["ContentType"] = "text/html";
  attachmentRecord["IsPrivate"] = false;
  attachmentRecord["Body"] =b64.encode(placeholder);// b64.encode(documentContent)
  
  
  try {
   var error = sforce.connection.create([attachmentRecord]);
   if (error.toString().indexOf("errors") != -1 ) {
    throw ("Document Save Error: " + error.toString());
   }
   
   opener.location.reload();
   if (lgm.debug.flag != true ) { //see debug statements remaining
    window.close();
   }
   
  }
  catch (err) {
   addMessage(err.toString());
   retval = false;
  }
 }
}
function isUrl(s) {
 var regexp = /(ftp|http|https|file):\/\/(\w+:{0,1}\w*@)–(\S+)(:[0-9]+)˜(\/|\/([\w#!:.™+=&%@!\-\/]))?/
 return regexp.test(s);
}

//-->
</script>
</head>

<body onload="setup()">
  <form id = "myform" name = "myform">
   <div class="lookup">
    <div class="bPageTitle">
     <div class="ptBody primaryPalette">
      <div class="content">
       <img src="/s.gif" alt="Lookup"  class="pageTitleIcon">
       <h1>Link Attachment</h1>
      </div>
     </div>
    </div>
    <table cellspacing = 0 cellpadding = 0 border = 0>
     <tr>
      <td width = 5>&nbsp;</td>
      <td width = 100% style = "padding:2px 10px 2px 2px; font-size: 9pt; font-weight: bold; color:#333;">Select the File</td>
      
      <td width = 5>&nbsp;</td>
     </tr>
     <tr>
      <td width = 5>&nbsp;</td>
      <td width = 100% style = "padding:2px 10px 2px 2px; font-size: 9pt; color:#333;">Ensure file path is accessible to entire organization.
      <br>Note: Do not move or rename file after linking
      <td width = 5>&nbsp;</td>
     </tr>
     <tr>
      <td width = 5>&nbsp;</td>
      <td width = 100%>&nbsp;</td>
      <td width = 5>&nbsp;</td>
     </tr>
     <tr>
      <td>&nbsp;</td>
      <td align = left><input  id="file" name="file" size="35" title="Type the path of the file or click the Browse button to find the file." type="file" /></td>
      <td>&nbsp;</td>
     </tr> 
     <tr>
      <td>&nbsp;</td>
      <td align = center>&nbsp;</td>
      <td>&nbsp;</td>
     </tr>
    
     <br>
     <tr>
      <td>&nbsp;</td>
      <td align = center>
       <div class="pBody" align = center>
        <input id = "submit" Name = "submit" class="btn" type=button value="Submit" onClick="submit2(myform.file.value);" disable = "true">
        <input id = "cancel" Name = "Cancel" class="btn" type=button value="Cancel" onClick="window.close();" disable = "true">     
       &nbsp;&nbsp;&nbsp;&nbsp;
       </div> 
       
      </td>
      <td>&nbsp;</td>
     </tr>
    </table>       
   </div>
   <DIV id="divDebug"></DIV> 
  </form> 
 </body>
</html>

 
I want to put a file url (file://host/path/filename.pdf) that points to a file on my local network in a field of type url so when a user clicks on it in a custom object detail view, it links to the document and opens it in the same way as a normal hyperlink using the http:// protocol.  When I do this though, the text "http://" gets appended to the field and it ends up looking like (http://file://host/share/filename.pdf) which doesn't work.  How can I make this work?
 

Message Edited by gsickal on 08-27-2007 07:34 AM

I am setting up our custom help links "help for this Page" for our custom objects. I am creating a s-control that provides context-specific help based who called this scontrol. Any way to find out who called me? Since the help screen opens up in a new window I thought I could use window.opener.url to parse for the calling object, but SF doesn't seem to be using standard ways to open the new help window because window.opener is null. Any ideas?
 
James Wikkerink
Municipal Software
A blank field in the spreadsheet and updating the associated record does not erase the former contents of the field to blank. I've tried NULL also. Both do not erase the field contents. Is there a way in the Excel Connector to blank out field contents?
 
James Wikkerink
Municipal Software
I have made a field Readonly both on the page layout and in field-level security selected Read-Only for all users. However, the field is still visible when in edit mode, allows users to enter data in it, and gets saved to the database. What else do I need to do to ensure that this field is view only?
 
James Wikkerink
Municipal Software
I have a managed package which has been published to the AppExchange.  I now want to remove a couple of items from the package and re-publish it.  But when I look at the package detail, most of the items in the package do not have a Remove link next to them.  How can I remove them?
I receive the following error when attempting to insert selected rows using the sforce connector, "Salesforce: Create() invalid range, missing data type, or other error, type is: weekly _c Overflow"
 
I retried loading the data and both times I received the error message after record 32,755 is inserted. I've tried loading only one row but was unsuccessful. I've also tried logging out of the session and logging back in which also did not work. I checked my storage usage and I am no where near my limit. Is there a parameter or something that needs to be altered?
 
Any help would be greatly appreciated.
 
Thanks!
 
 

I got great advice from a recent post, so maybe someone can help me with a sporadic message I receive, usually when opening a new Excel sheet after successfully running some queries (both insert and update).

The message is:

'sforce_connect1.xls' could not be found.  Check the spelling of the file name, and verify that the file location is correct.  If you are tyring to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.

Of course, I have never opened or created a file named sforce_connect nor sforce_connect1.

I am running sforce version 5.51, Excel 2003 (SP1) and have gotten this message both on Windows Server 2003 and Windows XP Professional (SP 2)

I have tried logging out (same error message), and it seems to trap me in an endless loop of error messages.

Any and all help greatly appreciated!

 

  • May 03, 2005
  • Like
  • 0