• Fletch
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
"You won't be able to query the case description from this query because the parent relationship on attachment is polymorphic."
 
 
I want to query the Parent.Account.xxx property of an Attachment, Parent being a Case.  As Simon F points out, this is impossible.  But I am able to make this query work for CaseComment because the relationship is not polymorphic: the type of the relationship being Case rather than Name in the latter...uh..case.
 
Any chance of creating a CaseAttachment?  Or is there some fiendishly clever way of letting the SOQL query engine know that it's a Case object as Parent?  I've read the API docs on polymorphics and I don't see the answer there...
 
yrs hopefully etc
  • November 01, 2007
  • Like
  • 0
First, I'm creating an object:
 
var featureInstance = new Sforce.Dynabean("Feature_Instance__c");
featureInstance.set("Feature__c", dynaBean.get("Feature__c"));
featureInstance.set("Case__c", "{!Case.Id}");

featureInstance.save();
And later in the same function, I want to set another object to lookup the featureInstance I created.  But how do I get the unique Id field from the featureInstance variable?
 
I've tried .get() with "Id", "Name", and "Feature_Instance__c" but no joy.
 
Can anyone help me here?  I'm still using the beta toolkit, by the way.
 
James
  • August 14, 2007
  • Like
  • 0
I'm hitting a problem where I am trying to do the following.
 
1) Querying a table of custom objects "Test_Case__c".
 
2) For each returned object, creating a new object that has a lookup to the Test Case object.
 
The WSDL for the "Test_Case__C" table does not appear to include any Id-type field that refers to the object itself.
 
What do I need to query/do to get the Id field I need for the lookup?
  • February 08, 2007
  • Like
  • 0
This is going to be quite a complex question - thanks to anyone who stays with it ;-)
 
I have a set of custom objects that represents types of telecoms device, their features, and how we test them for interoperabilty with our softswitch.
 
These objects are: Device Type (DT), Feature (F) and Test Case (TC).
 
DT and F have a many-to-many relationship via a linking object (DTxF).
 
F and TC have a one-to-many relationship (many TCs per F).
 
We are using the Case object to track testing of a particular device.  We set a "Device Type" lookup field in the Case pointing to the DT.
 
What we now want to do is as follows.
 
A single custom button click will invoke an S-Control that queries salesforce for the set of F for that DT.  It then creates a "Feature Instance" (FI) for each F, which is a custom object linking to F and to the Case.
 
Then, for each FI, we get the F and then query for all TCs for that F.  Then, for each TC we add a "Test Case Instance" (TCI) that links to the TC and the FI.
 
We've come up with the following not-quite-javascript code to do all this.  If anyone out there would like to comment on this and let us know if we've got the right approach, and provide any detailed advice on the code, it would be much appreciated!
 
 
_Start of Code_
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script>
<!--
function initPage() {
sforceClient.registerInitCallback(setup);
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);
}
//Use this function as the entry point for your DHTML and JAVASCRIPT processing
function setup() {
 
//F Here I want to get the Device Type object from the device type lookup field in the case object.
//   I think I need to use a merge field:  do I use {!Case.Device_TypeId__c} or {!Case.Device_Type__c}?
 
//F I think I then need to use something like the following to get the set of features to operate on.
//   Or do I use the ".search()" method here?
var queryResult = sforceClient.query("Select FeatureID from Feature where DeviceType equals <deviceType>, callbackFunction);
}
 
//F This is the callback function that will take the list of feature IDs and do the following.
//   -  Create a feature instance object linked to the feature and the Case.
//   -  Call a subroutine to add the test case instances.
function callbackFunction(queryResult) {
if (queryResult.className == "Fault") {
alert("There was an error: " + queryResult.toString());
} else {
if (queryResult.size > 0) {
 
//F  Set up an array of feature instance SObjects for the create request we're going to make.
SObject features[] = new SObject[queryResult.records.length];
var featureInstance;
for (var i=0;i<queryResult.records.length;i++) {
var dynaBean = queryResult.records[i];
 
//F  Set up the SObject array entry with the details of this feature instance.
featureInstance = new FeatureInstance();
featureInstance.setFeatureID(dynaBean.get(featureID));
featureInstance.setCaseID({!Case.Id});
features[i] = featureInstance;
} //end for loop
 
//F  Try the create operation.
var createResults = sforceClient.create(features);
 
//F  Process error and return values.
if (createResults.className == "Fault") {
alert("There was an error: " + createResult.toString());
} else {
if (createResult.size > 0) {
 
//F  Next up we call another function to process each returned feature instance, something like the following.
for (var i=0;i<createResult.records.length;i++) {
var dynaBeanTwo = createResult.records[i];
var featureSuccess = processFeature(dynaBeanTwo);
if !featureSuccess {
alert("Error processing feature: " + dynaBeanTwo.get(featureID) + "<br> Check this feature manually.");
}
} //end for loop
} else {
alert("No records created.");
}
} else {
alert("No records matched - check the Device Type object for linked Features.");
}
}
}
}
 
//F  Feature processing subroutine entry point.
function processFeature(dynaBean) {
 
//F  Query the DB again to get the test cases.
var queryResult = sforceClient.query("Select TestCaseID from TestCase where Feature equals " + dynaBean.get(featureID), featureCallbackFunction);
}
 
//F  Callback to continue processing features.
function featureCallbackFunction(queryResult) {
if (queryResult.className == "Fault") {
alert("There was an error: " + queryResult.toString());
} else {
if (queryResult.size > 0) {
 
//F  Set up an array of test case instance SObjects for the create request we're going to make.
SObject testCases[] = new SObject[queryResult.records.length];
var testCaseInstance;
for (var i=0;i<queryResult.records.length;i++) {
var dynaBean = queryResult.records[i];
 
//F  Set up the SObject array entry with the details of this testCaseInstance.
//    How to get the Fetaure Instance ID here - if we're in a callback I can't just pass in the old dynabean.  Do I need to create a global array?  Is there a better way?
testCaseInstance = new TestCaseInstance();
testCaseInstance.setTestCaseID(dynaBean.get(testCaseID));
testCaseInstance.setFeatureInstanceID(??HOW DO I GET THIS - THIS IS PER FEATURE INSTANCE I CREATED ABOVE??);
testCases[i] = testCaseInstance;
} //end for loop
 
//F  Try the create operation.
var createResults = sforceClient.create(testCases);
 
//F  Process error and return values.
if (createResults.className == "Fault") {
alert("There was an error: " + createResult.toString());
} else {
if (createResult.size > 0) {
 
//F Nothing to do here.
} else {
alert("No records matched - check the Device Type object for linked Features.");
}
}
}
}
}
//-->
</script>
</head>
<body onload="initPage()">
</body>
</html>
  • February 05, 2007
  • Like
  • 0

I am getting java.lang.reflect.InvocationTargetException when I am trying to edit and save an existing Test Class. The same test class, I am able to edit and save in another sandbox of the same Production instance. Any help is appreciated.

  • November 07, 2013
  • Like
  • 0
"You won't be able to query the case description from this query because the parent relationship on attachment is polymorphic."
 
 
I want to query the Parent.Account.xxx property of an Attachment, Parent being a Case.  As Simon F points out, this is impossible.  But I am able to make this query work for CaseComment because the relationship is not polymorphic: the type of the relationship being Case rather than Name in the latter...uh..case.
 
Any chance of creating a CaseAttachment?  Or is there some fiendishly clever way of letting the SOQL query engine know that it's a Case object as Parent?  I've read the API docs on polymorphics and I don't see the answer there...
 
yrs hopefully etc
  • November 01, 2007
  • Like
  • 0
I'm hitting a problem where I am trying to do the following.
 
1) Querying a table of custom objects "Test_Case__c".
 
2) For each returned object, creating a new object that has a lookup to the Test Case object.
 
The WSDL for the "Test_Case__C" table does not appear to include any Id-type field that refers to the object itself.
 
What do I need to query/do to get the Id field I need for the lookup?
  • February 08, 2007
  • Like
  • 0