Contributions
Re: Salesforce API update issue
***SOLVED*** Look in the folder where you extracted the Salesforce github files when originally installing the extension for the file: \testcomplete-salesforce-extension-main\src\script.sj Within the file is code in thethis.Update logic which builds a list of fields which are considered "updateable". You can add logic to that list builder to exclude fields from the.Push when the _metadata.fields[i].name contains "__pc", or for any other condition of field names which are throwing errors when trying to perform a.Update call to Salesforce. For Example: Changing: if (_metadata.fields[i].updateable) To: if ((_metadata.fields[i].updateable) && (_metadata.fields[i].name.search("__pc") < 0)) This will allow you to exclude problematic fields.2Views0likes1CommentRe: Salesforce API update issue
Hi rraghvani! Thanks, I was following the SOQL query format which was provided in the Examples provided with the github Salesforce / TestComplete extension which had this listed: // JavaScript example function Get_Names() { let names = Salesforce.Query("SELECT+Name+FROM+Account"); for (let i = 0; i < names.Count(); i++) { Log.Message(names.GetItem(i).Name); } } I did try your suggestion however, and still got the error. Status Code: 400 Status Text: Bad Request Body: [{"message":"Account: bad field names on insert/update call: Additional_E_mail__pc, Special_Needs__pc, Custom_Permissions__pc, Lic_Designation__pc, FinServ__ReferredByUser__pc, FinServ__CommunicationPreferences__pc, FinServ__ContactPreference__pc, Business_Phone__pc, Events_Experiences__pc, NAM_ID__pc, Formal_First_Name__pc, FinServ__CustomerTimezone__pc, Flag_for_Deletion__pc,15Views0likes3CommentsSalesforce API update issue
Hi Smartbear Community! I'm using the unsupported API github extension for common Salesforce API calls. I ran into an issue trying to edit/update existing ACCOUNT data. I'm using JS and have created a function I can passAccountName to, which then pulls the ID, and then does aSalesforce.Account.Get on the Salesforce instance. function Edit_Account(AccountName) { AccountName = aqString.Replace(AccountName,"'","\\'"); let AccountID = Salesforce.Query("SELECT+Id+from+Account+WHERE+Name+=+'" + AccountName + "'"); let AccountObj = Salesforce.Account.Get(AccountID.GetItem(0).Id); The issue I'm running into is an error posts back after attempting to .Send() the data back to SF. It seems like the.Getcall is pulling back a record with a lot of columns which I don't intend to change and when using.Send() I get the following error. Body: [{"message":"Account: bad field names on insert/update call: Additional_E_mail__pc, Special_Needs__pc, Custom_Permissions__pc, Lic_Designation__pc, FinServ__ReferredByUser__pc, FinServ__CommunicationPreferences__pc, FinServ__ContactPreference__pc, Business_Phone__pc, Events_Experiences__pc, NAM_ID__pc, Formal_First_Name__pc, FinServ__CustomerTimezone__pc, Flag_for_Deletion__pc, Customize_QPR__pc, FinServ__SourceSystemId__pc, etc. When I view the object forAccountObj, I see there's a lot of properties listed there that I don't care about. I'm only trying to change 1 property and send it back to SF. Any advice would be greatly appreciated!Solved49Views0likes7Comments- 5 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.6KViews0likes2Comments
Re: OAuth 2 Automation and JDBC calls
Hi, So when I press "get the token" it opens up our login pages, so I created 'automation' scripts to handle those login screens. Page 1 is the Enter User Name screen. Page 2, the Enter Password screen, Page 3, the Request authentication code screen, and Page 4, the Enter authentication code screen. What I'm trying to do is make a database call from within the automation script which goes to our database and gets the authentication token, rather than trying to get it from our emails, or text messages, which I would imagine is even harder to code into the automation script. But the SQL calls I'm making in the script shown below work fine if I pull them out into a separate Groovy script, just not inside the Oath2 automation script. So I'm curious why it's not working. After I get the authorization code from the database I intended on putting that in the field on the screen and pressing submit. Thank you, Roy Page 1 if (document.getElementById('txtUserName')) { document.getElementById('txtUserName').value = '${#Project#Prop_UserName}'; document.getElementById('btnNext').click(); } Page 2 if (document.getElementById('txtPassword')) { document.getElementById('txtPassword').value = '${#Project#Prop_Password}'; document.getElementById('btnSignin').click(); } Page 3 if (document.getElementById('MainContent_rblDeliveryMethods_0')) { document.getElementById('MainContent_rblDeliveryMethods_0').click(); document.getElementById('btnRequestCode').click(); } Page 4 if (document.getElementById('MainContent_AccessCodeRequiredFieldValidator')) { MyDBServer = "<removed for security reasons>"; MyUser = "<removed for security reasons>"; Mysql = sql.newInstance('jdbc:sqlserver://' + MyDBServer + ':1433;databaseName=<removed for security reasons>;integratedSecurity=true','','','com.microsoft.sqlserver.jdbc.SQLServerDriver'); Mydata = Mysql.firstRow("SELECT AC.AccessCode FROM UserAccessCodes AC JOIN Users US ON AC.UserID = US.UserID Where US.UserName = '"+MyUser+"' and AC.ActiveFlag = 1"); AuthCode = Mydata; Mysql.close(); document.getElementById('MainContent_AccessCodeRequiredFieldValidator').value = AuthCode; document.getElementById('btnConfirmCode').click(); }5 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.6KViews0likes3CommentsRe: OAuth 2 Automation and JDBC calls
Thanks for the feedback regarding SQL, but this code works in a Groovy script. What I need help with is understanding in what ways the script editor inside the OAuth 2 profile GUI differs from the capabilities of a script inside a Groovy script. Also, if there is a limitation on what you can do within the OAuth 2 automation profile scripting, what options exist for making a SQL database call from within the automation profile to get our unique 6-digit security token during OAuth 2 automation profile to validate the user? When running the code in the original post in the OAuth2 automation scripts GUI I get an error that says: ReferenceError: Can't find variable: Sql] if I use an "import Groovy.sql.Sql" at the beginning I get an error that says: Error: syntax error (scriptToValidate#1) So, it seems like the "Automation scripts for OAuther 2 profile" screen has some limitations on what sort of code can execute within it, but I'm not finding anything in the documentation, or online, to indicate that limitation. Thanks again!5 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.7KViews0likes6CommentsOAuth 2 Automation and JDBC calls
Hi, I'm creating an OAuth 2 automation script to handle our login screen when calling an /api/jwt token retrieval. When getting the token, our login pages appear, for which I have added 4 pages of Automation to handle entering User Name, Password, etc. Page 1: Enter User Name screen Page 2: Enter Password screen Page 3: Request security token via Email or Text Page 4: Enter valid security code which was received via Email or Text, and press Next Once I reach Page 4, I realized I had no way of getting the security code which our website sends me. So I began to consider my options. I felt like a JDBC call would work great and I could get the security token directly from the database. When I tried creating JDBC calls within the OAuth Automation script profile, it began to throw all sorts of errors, not being able to import groovy.sql.Sql, seeing a Sql.newInstance call as ReferenceError: Can't find variable: Sql] I thought maybe if I could call an outside Groovy script to return the value I might try that. So I created a script file which works, but attempting this type of code in the OAuth 2 automation screen fails. MyDBServer = "<removed>" MyUser = "<removed>" MyDBName = "<removed>" Mysql = Sql.newInstance('jdbc:sqlserver://' + MyDBServer + ':1433;databaseName='+MyDBName+';integratedSecurity=true','','','com.microsoft.sqlserver.jdbc.SQLServerDriver') Mydata = Mysql.firstRow("SELECT MyCode FROM secured.MyAccessCodes AC JOIN secured.MyTable US ON AC.MyID = US.MyID Where US.UserName = '"+MyUser+"' and AC.ActiveFlag = 1") log.info(Mydata) Mysql.close() Any suggestions? I'd like to be able to add the database call directly into Step 4 of the OAuth 2 automation script in order to enter the security code into the window.5 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.7KViews0likes8Comments