• JodieM
  • NEWBIE
  • 20 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

Hi, I'm new to Salesforce development and don't know enough about Javascript.

 

I have taken an example of Javascript to update a Case Record and it works with a text value. I would like to update the case with a value queried from another object (there is no relationships between the two objects so it can't be done via a workflow).

 

I am pretty sure the error in my code is something to do with Javascript Arrays because I can verify that the Query on my lookup Object is returning a value.

 

Could someone please help me out and point me in the right direction with how to get the value out of the query to use in the update of the Case.

 

Thanks

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}

var updateRecord = new Array(); 
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1";

result = sforce.connection.query(myquery);
records = result.getArray("records");

var lkupquery = "Select LookupValue__c from CustomObject__c where OwnerId = '{!$User.Id}' and Value__c < 10 limit 1";
var lkupresult = sforce.connection.query(lkupquery);
var lkuprecords = lkupresult.getArray("lkuprecords");

if (lkuprecords.length == 1) {
  var LkupVal = lkuprecords[0];
} else {
  alert("Something went wrong here");
}

if(records[0])
{
    var update_Case = records[0];
    update_Case.MyTextField__c = LkupVal;
    updateRecord.push(update_Case);
}

result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;

My problem starts with the line "var lkuprecords = lkupresult.getArray("lkuprecords");" 

 

I am trying to update the case field MyTextField__c with the LookupValue__c from the CustomObject__c

  • February 28, 2012
  • Like
  • 0
Hi,

I get error 
Challenge Not yet complete... here's what's wrong:
Could not find a Service Appointment with the Subject of 'Drill Cable Holes'.

I tried this twice in the playground and completed the first part with no issues.  Screen shot attached.

User-added image

Hi, I'm new to Salesforce development and don't know enough about Javascript.

 

I have taken an example of Javascript to update a Case Record and it works with a text value. I would like to update the case with a value queried from another object (there is no relationships between the two objects so it can't be done via a workflow).

 

I am pretty sure the error in my code is something to do with Javascript Arrays because I can verify that the Query on my lookup Object is returning a value.

 

Could someone please help me out and point me in the right direction with how to get the value out of the query to use in the update of the Case.

 

Thanks

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}

var updateRecord = new Array(); 
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1";

result = sforce.connection.query(myquery);
records = result.getArray("records");

var lkupquery = "Select LookupValue__c from CustomObject__c where OwnerId = '{!$User.Id}' and Value__c < 10 limit 1";
var lkupresult = sforce.connection.query(lkupquery);
var lkuprecords = lkupresult.getArray("lkuprecords");

if (lkuprecords.length == 1) {
  var LkupVal = lkuprecords[0];
} else {
  alert("Something went wrong here");
}

if(records[0])
{
    var update_Case = records[0];
    update_Case.MyTextField__c = LkupVal;
    updateRecord.push(update_Case);
}

result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;

My problem starts with the line "var lkuprecords = lkupresult.getArray("lkuprecords");" 

 

I am trying to update the case field MyTextField__c with the LookupValue__c from the CustomObject__c

  • February 28, 2012
  • Like
  • 0

Hi,

 

I could't manage to figure out how (if its possible) to translate the Standard Object / Standard field labels ( eg, Account objct / "Account name" field)?

I tried to use the Translation Workbench, but there I can only change the custom field labels.