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
Adnan81Adnan81 

S-Control

Hi,

 

I have a S-Control which is working fine, but a issue that I am having now. I have a Text field and when that field is populated straight for example: NY,CT, NJ without pressing enter s-control works fine on save, but when you populate the field pressing enter for example:

NY

CT

NJ

 

This gives a white screen on save.

 

The s-control is hanging up because the ENTER key is used within the "SIP NOTES" field. I am trying to find a way to pass the entire contents of the SIP NOTES field, including any carriage return characters, via the s-control [Pre-Order Conversion to Oppty & Acct].

 

Thanks in advance

Adnan

Imran MohammedImran Mohammed

I hope you are using some key events.

Can you post the code relating to what happens when key is pressed in text field?

Adnan81Adnan81

Thanks for looking into this. Below is the code. Just to let you know this S-Control is behind a Button that says convert. This button is in a custom object called preorder and it converts from preorder to opportunity.

 

 

html> 
<head> 
<script type="text/javascript" src="/js/functions.js"></script> 
<script src="/soap/ajax/10.0/connection.js"></script> 
</head> 

<body> 
<script> 

var NULL=""; 
var msg=""; 
var processFlag=0; //Val: 0-Account or Opportunity record not created 1-Account created 
var URL="/{!Pre_Order__c.Id}"; 

//CHECK IF CONVERTED 
if ({!Pre_Order__c.Processed__c}) { 
msg = "Pre-Order already processed (Converted)"; 
} //END IF ({!Pre_Order__c.Processed__c}) 

//PRE-ORDER NOT CONVERTED 
else { 

//QUERY PRE-ORDER FOR MULTI-LINE AND SPECIAL CHARACTER FIELDS 
var queryPreorder=sforce.connection.query("Select Account_Name__c, Customer_Contact__c, Notes__c, Ala_Carte_Packages__c , IO_Offer__c, Services_Purchased__c From Pre_Order__c where id='{!Pre_Order__c.Id}'"); 
var preorderRecords = queryPreorder.getArray('records'); 
var preorderRecord = preorderRecords[0]; 

//CREATE ACCOUNT RECORD 
var account = new sforce.SObject("Account"); 
account.Name = preorderRecord.Account_Name__c; 
account.OwnerId = "{!Pre_Order__c.OwnerId}"; 
account.Phone = "{!Pre_Order__c.Phone__c}"; 
account.Phone2__c = "{!Pre_Order__c.Phone_2__c}"; 
account.Fax = "{!Pre_Order__c.Fax__c}"; 
account.Email__c = "{!Pre_Order__c.Email__c}"; 
account.BillingStreet = "{!Pre_Order__c.Service_Street__c}"; 
account.BillingCity = "{!Pre_Order__c.Service_City__c}"; 
account.BillingState = "{!Pre_Order__c.Service_State__c}"; 
account.BillingPostalCode = "{!Pre_Order__c.Service_Zip_Postal_Code__c}"; 
account.Customer_Contact__c = preorderRecord.Customer_Contact__c; 
account.Description = preorderRecord.Notes__c; 

createAccount=sforce.connection.create([account]); 

accountId=createAccount[0].id; 
var accountId15=accountId.substr(0,15); //CONVERT ACCOUNT ID to 15 vs 18 CHAR 

//BUILD MSG AFTER CREATE ACCOUNT 
if (createAccount[0].getBoolean("success")) { 
msg += "Account Created - " + account.Name + " \n"; 
processFlag=1; //ACCOUNT CREATED 
} //END IF (createAccount[0].getBoolean("success")) 

else { 
msg += "Account NOT Created - Notify System Adminstrator"; 
} //END ELSE (createAccount[0].getBoolean("success")) 

if (processFlag=1) { //ACCOUNT WAS CREATED, CREATE OPPORTUNITY 

//CREATE OPPORTUNITY RECORD 
var closeDate = new Date(); 
closeDate.setDate( closeDate.getDate()); 
var opp = new sforce.SObject("Opportunity"); 


opp.Addtl_BCOOL_Svces__c = "{!Pre_Order__c.Additional_OOL_Svce_s_49_95__c}"; 
opp.BCOOLOffer__c = "{!Pre_Order__c.OV_Offer__c}"; 
opp.BOOST__c = "{!Pre_Order__c.Boost__c}"; 
opp.CloseDate = closeDate; //***MANDATORY Today ** 
opp.Customer_Contact__c = preorderRecord.Customer_Contact__c; 
opp.IOOffer__c = preorderRecord.IO_Offer__c; 
opp.NYMARegion__c = "NYC"; //***MANDATORY Initially NYC then None 
opp.Name = preorderRecord.Account_Name__c; //***MANDATORY From Pre-Order ** 
opp.OccupancyRateofpeople__c = "{!Pre_Order__c.Occupancy_Rate_of_people__c}"; 
opp.OwnerId = "{!Pre_Order__c.OwnerId}"; 
opp.Pre_Order_ID__c = "{!Pre_Order__c.Id}"; 
opp.Services_Purchased__c = preorderRecord.Services_Purchased__c; //***MANDATORY From Pre-Order 
opp.StageName = "Qualified"; //***MANDATORY Initially Qualfied then Sales Contract Signed 
opp.Static_IP__c = "{!Pre_Order__c.Static_IP__c}"; 
opp.AccountId = accountId; 
opp.iO_Ala_Carte__c = preorderRecord.Ala_Carte_Packages__c; 
opp.ov_num_Enhanced_Wiring_jacks_75__c = "{!Pre_Order__c.ov_of_Inside_Wiring_jacks_75__c}"; 
opp.Pre_Order__c = "{!Pre_Order__c.Id}"; 
opp.Sub_Agent__c = "{!Pre_Order__c.Sub_AgentId__c}"; 
opp.Central_Station_Monitoring__c ="{!Pre_Order__c.Central_Station_Monitoring__c}"; 
opp.Buyout_Type__c ="{!Pre_Order__c.Buyout_Type__c}"; 
opp.SalesRepID__c ="{!Pre_Order__c.Rep_ID__c }"; 
opp.Sales_Agent_Rep_ID__c ="{!Pre_Order__c.Agent_Rep_ID__c}"; 
opp.description = preorderRecord.Notes__c; 
opp.Corp__c = "{!Pre_Order__c.Corp__c}"; 
opp.Account1__c = "{!Pre_Order__c.Account__c}"; 
opp.LeadSource = "Sales Agent";
opp.Toll_Free__c= "{!Pre_Order__c.Toll_Free__c}"; 
opp.Customers_Email__c= "{!Pre_Order__c.Email__c}"; 
opp.WiFi__c= "{!Pre_Order__c.WiFi__c}"; 
opp.Location_Category__c= "{!Pre_Order__c.Location_Category__c}"; 
opp.Customer_Area_Seating__c= "{!Pre_Order__c.Customer_Area_Seating__c}"; 
opp.ULTRA__c = "{!Pre_Order__c.ULTRA__c}"; 
opp.Tax_ID__c = "{!Pre_Order__c.Tax_ID__c }"; 
opp.Headquarters_Email__c = "{!Pre_Order__c.Agent_Email__c }"; 
opp.Trunk_Type__c = "{!Pre_Order__c.Trunk_Type__c }"; 
opp.of_SIP_Sessions__c = "{!Pre_Order__c.of_SIP_Sessions__c }"; 
opp.of_Additional_Blocks__c = "{!Pre_Order__c.of_Additional_Blocks__c }"; 
opp.of_SIP_DID_s_Ported__c = "{!Pre_Order__c.of_SIP_DID_s_Ported__c}"; 
opp.PBX_System__c = "{!Pre_Order__c.PBX_System__c}"; 
opp.Trunk_Switch_Type__c = "{!Pre_Order__c.Trunk_Switch_Type__c}"; 
opp.D_Channel__c = "{!Pre_Order__c.D_Channel__c}"; 
opp.B_Channel__c = "{!Pre_Order__c.B_Channel__c}"; 
opp.Internal_Clocking__c = "{!Pre_Order__c.Internal_Clocking__c}"; 
opp.Pilot_TN__c = "{!Pre_Order__c.Pilot_TN__c}"; 
opp.SIP_BTN__c = "{!Pre_Order__c.SIP_BTN__c}"; 
opp.SIP_BTN_Carrier__c = "{!Pre_Order__c.SIP_BTN_Carrier__c}"; 
opp.SIP_Directory_Listing__c = "{!Pre_Order__c.SIP_Directory_Listing__c}"; 
opp.DID_Block_1_Start__c = "{!Pre_Order__c.DID_Block_1_Start__c}"; 
opp.DID_Block_2_Start__c = "{!Pre_Order__c.DID_Block_2_Start__c}"; 
opp.DID_Block_3_Start__c = "{!Pre_Order__c.DID_Block_3_Start__c}"; 
opp.DID_Block_4_Start__c = "{!Pre_Order__c.DID_Block_4_Start__c}"; 
opp.DID_Block_5_Start__c = "{!Pre_Order__c.DID_Block_5_Start__c}"; 
opp.DID_Block_6_Start__c = "{!Pre_Order__c.DID_Block_6_Start__c}"; 
opp.DID_Block_7_Start__c = "{!Pre_Order__c.DID_Block_7_Start__c}"; 
opp.DID_Block_8_Start__c = "{!Pre_Order__c.DID_Block_8_Start__c}"; 
opp.DID_Block_9_Start__c = "{!Pre_Order__c.DID_Block_9_Start__c}"; 
opp.DID_Block_10_Start__c = "{!Pre_Order__c.DID_Block_10_Start__c}"; 
opp.DID_Block_1_End__c = "{!Pre_Order__c.DID_Block_1_End__c}"; 
opp.DID_Block_2_End__c = "{!Pre_Order__c.DID_Block_2_End__c}"; 
opp.DID_Block_3_End__c = "{!Pre_Order__c.DID_Block_3_End__c}"; 
opp.DID_Block_4_End__c = "{!Pre_Order__c.DID_Block_4_End__c}"; 
opp.DID_Block_5_End__c = "{!Pre_Order__c.DID_Block_5_End__c}"; 
opp.DID_Block_6_End__c = "{!Pre_Order__c.DID_Block_6_End__c}"; 
opp.DID_Block_7_End__c = "{!Pre_Order__c.DID_Block_7_End__c}"; 
opp.DID_Block_8_End__c = "{!Pre_Order__c.DID_Block_8_End__c}"; 
opp.DID_Block_9_End__c = "{!Pre_Order__c.DID_Block_9_End__c}"; 
opp.DID_Block_10_End__c = "{!Pre_Order__c.DID_Block_10_End__c}"; 
opp.of_Digits_for_PBX__c = "{!Pre_Order__c.of_Digits_for_PBX__c}"; 

opp.SIP_Notes__c = "{!Pre_Order__c.SIP_Notes__c}"; 

if ( "{!Pre_Order__c.Trunk_Type__c}" != "" ) {opp.RecordTypeId = "0120000000097Y1";} 

opp.Number_Lines_Ported__c = "{!Pre_Order__c.ov_of_Lines_Ported__c}"; 

if ( "{!Pre_Order__c.Qty_of_Additonal_Outlets__c}" != "" ) { 
opp.QtyofAdditonalOutlets__c = "{!Pre_Order__c.Qty_of_Additonal_Outlets__c}"; //DOU 
} 

if ( "{!Pre_Order__c.Qty_of_Cable_Boxes__c}" != "" ) { 
opp.QtyofCableBoxes__c = "{!Pre_Order__c.Qty_of_Cable_Boxes__c}"; //DOU 
} 


try { 
createOpp=sforce.connection.create([opp]); } 
catch (error) { 
alert (error); 
} 

oppId=createOpp[0].id; 
var oppId15=oppId.substr(0,15); //CONVERT OPPORTUNITY ID to 15 vs 18 CHAR 


if (createOpp[0].getBoolean("success")) { 
msg += "Opportunity Created - " + preorderRecord.Account_Name__c + " \n"; 
} //END IF (createOpp[0].getBoolean("success")) 

else { 
msg += "Opportunity Not Created - Notify System Adminstrator (DELETE ACCOUNT)" + " \n"; 
processFlag=0; //OPPORTUNITY NOT CREATED, RESET FLAG 
} //END ELSE (createOpp[0].getBoolean("success")) 

//CHECK IF BOTH ACCOUNT AND OPPORTUNITY WERE CREATED 
if (processFlag=1) { //ACCOUNT AND OPPORTUNITY WERE CREATED, UPDATE PRE-ORDER WITH PROCESSED 

//UPDATE PRE-ORDER TO PROCESSED (CONVERTED) 
var preorder = new sforce.SObject("Pre_Order__c"); 
preorder.Processed__c=true; 
preorder.Id="{!Pre_Order__c.Id}"; 
preorder.CVC_Status__c="Pre-Order Processed"; 
updatePreorder=sforce.connection.update([preorder]); 

if (updatePreorder[0].getBoolean("success")) { 
msg += "Pre-Order Processed" + " \n"; 
} //END IF (updatePreorder[0].getBoolean("success")) 

else { 
msg += "Pre-Order NOT set to processed - Notify System Administrator (Manually set Pre-Order Processed)" + " \n"; 
} //END ELSE (updatePreorder[0].getBoolean("success")) 


//*** APPEND URL TO RESET OPPORTUNITY FIELDS 
URL = "/006/e"; 
URL += "?id="+ oppId15; 
URL += "&opp11="+ "Sales Contract Signed"; 
URL += "&00N00000004E1Py=" + NULL; //NYMA REGION to null 
//URL += "&00N00000006pEAq=" + NULL; //ov LOA 
//URL += "&00N00000004lLKr=" + NULL; //Rep ID to null 
URL += "&retURL=/a0T/o"; 

}//END IF (processFlag=0) 
}//END IF (processFlag=1) 
}//END ELSE ({!Pre_Order__c.Processed__c}) 

alert (msg); 
parent.frames.location.replace(URL); 

</script> 
</body> 
</html>