• Mel Lisau
  • NEWBIE
  • 65 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 30
    Replies
How can i parse SOQL query using the TSQLStatementReader.ParseStatements ?
I have a SOQL query :
var query = select id, Order.Id, Order.Contract.Id, Order.Contract.Account.Id, Order.Contract.Account.Owner.Id from OrderItem
and I am trying to parse this into columns by using the following:
var statement = TSQLStatementReader.ParseStatements(query.Replace("\n", " ").Replace("\r", " "));

But if i debug there is nothing in the From property of the object, it seems to be going to the Group By and the Select property is null as well ?
How can i do the parsing or is there a SOQLParser class ?
I am trying to check if a change tables exists in Salesforce by calling
var name = "acme_npsp__Allocation_c__c"; try { salesforceObject = _service.describeSObject(name); return sObject; } catch (Exception ex) { error = ex.Message; }
but it gives an error:
INVALID_TYPE: salesforceObject type 'acme_npsp__Allocation_c__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

I have an object npsp__Allocation__c installed from a managed package. Now i want to prefix it with my own prefix , as above acme so i am wanting acme_npsp__Allocation__c, but it thinks the namespace is acme_npsp because of the double __. Is there a way to ignore the double _. I can remove it when i create the object, but the api name will change to acme_npsp_Allocation__c, and when i try to access fields , it will be looking for npsp__Allocation__c, custom object which now doesnt exist ?

The error says it cant be installed from API, can i do it via a package, if so is there an example ?
I am currently authenticating into Salesforce by using
Service URL, username and password+securitytoken.

I want users to authenticate using OAuth2 now,(take out the username & password portion) but still make my SOAP calls so I have created a connected app and retrieved my client id and client secret.

If i use the following https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id= <client_id>&client_secret=<client_secret>&username=<username>&password=<password>+ <securitytoken>

Cant i just stay and use normal username , password+securitytoken , what is the real purpose of the Connected App ?

Or do i need to send to https://login.salesforce.com/services/oauth2/authorize ? 

I am trying to do this in a c# mvc app.

Any help with steps involved would be great ?

So basicaly i want to authenticate using my new connected app , but still make Soap calls , not REST , is this possible and do i need to use th new token in my calls to Soap , like adding it to the sessionid ?
 
How can i login to Salesforce that has Multi Factor Authentication on API calls?

I have started using MFA in Salesforce. I can successfully configure the setting "Multi-Factor Authentication for User Interface Logins" and use the Salesforce Authenticator app.

I have now enabled "Multi-Factor Authentication for API Logins", but in my C# app , the user enters Username, Password and Security Token.
The user logs into Salesforce via the following code:
SFService = new SalesForceEnterpriseService.SforceService() { Timeout = 80000, Url = "https://login.salesforce.com/services/Soap/u/52.0"}; LoginResult result = SFService.login(Username, Password + Token);

But now i get the error:
INVALID_LOGIN: Invalid username, password, security token; or user locked out.
But when i uncheck Multi Factor for API calls i can login successfully.

How can i now login a user if MFA for API calls is enabled and will i be able to make other API calls like getting Entity fields ?
 
If i want to creat an Account withe Name lest say "TestAcct1" , how many api calls are made to api to create it ? Does it check existence and if there then update , thats 2 already .
I was after the lifecycle for creating entitites. 
I have a scenario where 1 Account has 50 Contacts and if i wanted to create that then would it do check for existence , update and so on that would make over 100 calls to the api . 
Is there a quicker way to do this ?
I have a Salesforce project. I use SOAP API to login and that is successful. 
When our clients need to construct a query to a sObject they dont know all the field names, relationships etc . So they construct a very minimal query for lets say update / upsert .
What i am hoping to do is give them something like Query Builder Tool. 
So is there a way that I can add this to my Visual Studio project and display the UI to the user ?

Thanks
I am tryng to use OAuth to authenticate rather that the traditional username , password.
I can successfuly authenticate and receive back a Instanceurl and token.

But how can i construct a SOAP call using these ?
I tried to follow this link but there is no example.

https://developer.salesforce.com/blogs/developer-relations/2011/03/oauth-and-the-soap-api.html

I have tried to  make a request as follows:

strng SOAP_API_SOBJECT_ENDPOINT = "/services/Soap/u/51.0/";
string sobject = "Account"
Account acct = new Account { Name = $"Test123  ", Description = $"Test Description 123[" };

          string restendpoint = InstanceUrl + SOAP_API_SOBJECT_ENDPOINT + sobject;
            var json = JsonConvert.SerializeObject(acct);
            var request = new HttpRequestMessage(HttpMethod.Post, restendpoint);
            request.Headers.Add("Authorization", "Bearer " + AuthToken);
            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            request.Headers.Add("X-PrettyPrint", "1");
            request.Content = new StringContent(json, Encoding.UTF8, "application/json");
            var response = client.SendAsync(request).Result;
            return response.Content.ReadAsStringAsync().Result;

The result is Internal Server Error.

Is this the correct way to use OAuth with Soap API ?




 
I am new to the Rest API wihin Salesforce and have a few queries.

1) With the Rest API ,do i need to create a connected app within my org before I can connect  and do all users use the same Secret Key ?  
2) What is required to implement OAuth authentication and do i need too ?
3) With the Rest API ,can i still use the SOQL or is there a better feature for  querying data ?
4) Can i query API endpoints and filter the response ?
5) Can i use the Rest Api to integrate data into Salesforce ?



Would one use the Rest API over Soap because SOAP requires downloading a WSDL file, Converting the WSDL files to regular classes and then invoking methods on those objects ?

Thanks
I have custom objects , say     My_Account__c, My_Contact__c , My_Address_c and others. 
I can successfully delete all custom objects , and then I go to run the empty recycle bin by using :

 public void EmptyRecycleBin(String[] ids)
        {
                EmptyRecycleBinResult[] result = _myservice.emptyRecycleBin(ids);
                for (int i = 0; i < result.Length; i++)
                {
                    EmptyRecycleBinResult result = emptyRecycleBinResults[i];
                }           
        }

I get a EmptyRecycleBinResult result of success, but when i go to the Create-Objects, I can see my custom object is deleted , but it remains in the Deleted Objects. I thought the EmptyRecyceBin would purge the objects in there , 
How can i permanently delete these custom objects ? 
I have a destructivechanges and package.xml file+

package.xm
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>51.0</version>
</Package>

Destructivechanges.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>myCustomObject__c</members>
        <name>CustomObject</name>
    </types>
</Package>


I have tried with the latest API Version and even though I have specified only 1 custom Object to delete, it actually deletes all of them and even the flag purgeondelete doesnt actually purge , I still have to manually delete the deleted objects, why is this ?
I have deleted a number of Objects and they have relationships and links. Is there an SOQL call or any other type of way i can make to clear these from the "Deleted Objects" instead of manually going and deleting them ?
I have custom objects in Salesforce that i delete , but if i lok in Salesforce it says "deleted objects(2)". I need to go into there and Erase.
At the moment i am doing the following
custids is a string[] of the salesforce id for that object.

sfservice.DeleteResult[] deleteResult = mysrvc.delete(custids);

and then

sfservice.EmptyRecycleBinResult[] emptyresult= mysrvc.emptyRecycleBin(custids);

But when i look in Salesforce , I can still see the objects as Deleted Objects and I need to go in manually and delete them

How can i delete them permanently ?
I have a SandBox instance and have registered my triggers and classes and the test classes have passed the 75% requirement.
I also have a Production instance and these are now successfully on my Production instance. No problem there.

But in my application I have a connection to my Production instance and if i need to update a trigger in production i delete it (because i dont know what the user has changed) and then try to register , but because it is Production it wont allow me because it needs to pass tests. 
My question is , once the triggers and test classes are registered with Production , can i modify the body of the triggers if required and body of the test classes if required without having to rerun on Sndbox first and then redeploy to Production ?

I have a SOQL call as follows:
select Account.AccountNumber, Account.AccountSource, Account.Active__c, Account.AnnualRevenue, Account.BillingAddress,
Account.CreatedById, Account.CreatedDate, Account.CustomerPriority__c,
Account.Name, Account.NumberOfEmployees, Account.NumberofLocations__c, Account.OwnerId, Account.Ownership, 
 Account.Site, Account.SLA__c, Account.SLAExpirationDate__c, Account.SLASerialNumber__c,
 Account.SystemModstamp, Account.TickerSymbol, Account.Tradestyle, Account.Type, Account.UpsellOpportunity__c, 
   (select Sequence__c, Action__c from AcmeCo_Account_c__r where Processed__c = false and IDM__c = 'TEST1' ) 
from Account where Account.Id in (select Link__c from AcmeCo_Account__c where IDM__c = 'TEST1' and Processed__c = false) 

But it give an error:
(select Sequence__c, Action__c from AcmeCo_Account_c__r where Processed__c
                                    ^
ERROR at Row:17:Column:40
Didn't understand relationship 'AcmeCo_Account_c__r' in FROM part of query call. 
If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. 

The custom table is created . 
How can i avoid this or correct the query ?

thanks

 
I need to sign up a new Organization in Salesforce and do some development in .Net. But i want to know when a user signs up are they given a Production instance and SanbBox instance by default ? or is Production instance by default always given and the user has to set up a SandBox for testing ?
I have the following query:

var queryResult = binding.query("SELECT Id, Username, LastName, FirstName, Name, IsActive FROM User");

I get 7 records , but how can i convert this to a dataset or list or JSON using C# in order to perform Linq operations ?

thanks
Hi , 
I have a Production instance and i need to run api calls but require the  'Manage Sandbox' permission for a user in Production , 
What is the permission and how can i set this withing Production ?

thanks
If i have lets say a Production , SandBox and Developer Edition in Salesforce. Is there a way I can login to one , probably Production and retrieve all instances registered to the Organisation. So logging into Production I can make some sort of ap[i call or apex call that will give me all instances assocaiated to this Organisation. (a link between Prod , Sandbox and Developer)
There is a rest call as follows;
GET /services/data/v40.0/tooling/query/?q=Select+id,SandboxName+from+SandboxInfo
But i am not using rest at the moment , only Soap , can i use an equivalent Soap call ?


Thanks
I am trying to create a test for "after insert" on OrderItem.,
I have so far the following:


@isTest 
 public static testMethod void MyTestOrderItem()   { 
   List<Account> AccountList = new List<Account>();
   Account Account_0 = new Account( Name='NAME1');
   AccountList.add(Account_0);
   Account Account_1 = new Account( Name='NAME2');
   AccountList.add(Account_1);
   insert AccountList;


    Product2 p = new Product2();
    p.Name = ' Test Product ';
    p.Description='Test Product Entry 2';
    p.productCode = 'ABCD';
    p.isActive = true;
    insert p;


   PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];
   Id pricebookId = pb2Standard.Id;

    // Insert PricebookEntry=
    PricebookEntry standardPrice = new PricebookEntry();
    standardPrice.Pricebook2Id = pricebookId;
    standardPrice.Product2Id = p.Id;
    standardPrice.UnitPrice = 1;
    standardPrice.IsActive = true;
    standardPrice.UseStandardPrice = false;
    insert standardPrice;


  List<Order> OrderList = new List<Order>();
  Order Order_0 = new Order(Pricebook2Id= pricebookId,  Status='Draft',Name='4TJI5',EffectiveDate=Date.Today(),AccountId=AccountList[0].Id);
  OrderList.add(Order_0);
  Order Order_1 = new Order(Pricebook2Id= pricebookId, Status='Draft',Name='0TXZU',EffectiveDate=Date.Today(),AccountId=AccountList[0].Id);
  OrderList.add(Order_1);
  insert OrderList;
 
  List<OrderItem> OrderItemList = new List<OrderItem>();
  OrderItem OrderItem_0 = new OrderItem(Product2id = p.id , PriceBookEntryId=standardPrice.Id, Description='FD3G8',OrderId=OrderList[0].Id);
  OrderItemList.add(OrderItem_0);
  OrderItem OrderItem_1 = new OrderItem( Product2id = p.id, PricebookEntryId=standardPrice.Id, Description='PB4DM',OrderId=OrderList[0].Id);
  OrderItemList.add(OrderItem_1);
  insert OrderItemList;

}

Would this help in my unit test , or is there a simpler test for OrderItem ?
Hi,
I am using a ternary operator like the following 
MyObject has a field "Name"



String WebSite = ‘Yahoo.com’;
String WebSiteResult = WebSite != null ? WebSite : ‘Google.com’;

But how can i do something like this 

MyObject obj = new MyObject();
String WebSite = ‘Yahoo.com’;
String WebSiteResult = WebSite != null ? { WebSite; obj.Name ='TestName' } : ‘Google.com’;
It says invalid '  {"

 
If i need to creat an Order , I need to first creat an Account and then assign the AccountId to the Order, like the following
 Account a = new Account();
 a.Name = 'Test';
 insert a;    

 Order order = new Order(     
        AccountId = a.Id,
        Status='Draft',
        EffectiveDate = Date.today());
 insert order;

Is there a way to create an Order and the required fields will be populated including the AccountId that is linked to the Account?
Reason is that I am looking at dynamically crating tests for my SObjects.
So if i have a trigger on Order (after insert) , I want to create a test for this but do it through a dynamic templating that I can use for al SObjects .

Thanks
I am trying to check if a change tables exists in Salesforce by calling
var name = "acme_npsp__Allocation_c__c"; try { salesforceObject = _service.describeSObject(name); return sObject; } catch (Exception ex) { error = ex.Message; }
but it gives an error:
INVALID_TYPE: salesforceObject type 'acme_npsp__Allocation_c__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

I have an object npsp__Allocation__c installed from a managed package. Now i want to prefix it with my own prefix , as above acme so i am wanting acme_npsp__Allocation__c, but it thinks the namespace is acme_npsp because of the double __. Is there a way to ignore the double _. I can remove it when i create the object, but the api name will change to acme_npsp_Allocation__c, and when i try to access fields , it will be looking for npsp__Allocation__c, custom object which now doesnt exist ?

The error says it cant be installed from API, can i do it via a package, if so is there an example ?
I have a Salesforce project. I use SOAP API to login and that is successful. 
When our clients need to construct a query to a sObject they dont know all the field names, relationships etc . So they construct a very minimal query for lets say update / upsert .
What i am hoping to do is give them something like Query Builder Tool. 
So is there a way that I can add this to my Visual Studio project and display the UI to the user ?

Thanks
I am new to the Rest API wihin Salesforce and have a few queries.

1) With the Rest API ,do i need to create a connected app within my org before I can connect  and do all users use the same Secret Key ?  
2) What is required to implement OAuth authentication and do i need too ?
3) With the Rest API ,can i still use the SOQL or is there a better feature for  querying data ?
4) Can i query API endpoints and filter the response ?
5) Can i use the Rest Api to integrate data into Salesforce ?



Would one use the Rest API over Soap because SOAP requires downloading a WSDL file, Converting the WSDL files to regular classes and then invoking methods on those objects ?

Thanks
I have custom objects , say     My_Account__c, My_Contact__c , My_Address_c and others. 
I can successfully delete all custom objects , and then I go to run the empty recycle bin by using :

 public void EmptyRecycleBin(String[] ids)
        {
                EmptyRecycleBinResult[] result = _myservice.emptyRecycleBin(ids);
                for (int i = 0; i < result.Length; i++)
                {
                    EmptyRecycleBinResult result = emptyRecycleBinResults[i];
                }           
        }

I get a EmptyRecycleBinResult result of success, but when i go to the Create-Objects, I can see my custom object is deleted , but it remains in the Deleted Objects. I thought the EmptyRecyceBin would purge the objects in there , 
How can i permanently delete these custom objects ? 
I have a destructivechanges and package.xml file+

package.xm
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>51.0</version>
</Package>

Destructivechanges.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>myCustomObject__c</members>
        <name>CustomObject</name>
    </types>
</Package>


I have tried with the latest API Version and even though I have specified only 1 custom Object to delete, it actually deletes all of them and even the flag purgeondelete doesnt actually purge , I still have to manually delete the deleted objects, why is this ?
I have deleted a number of Objects and they have relationships and links. Is there an SOQL call or any other type of way i can make to clear these from the "Deleted Objects" instead of manually going and deleting them ?

I have a SOQL call as follows:
select Account.AccountNumber, Account.AccountSource, Account.Active__c, Account.AnnualRevenue, Account.BillingAddress,
Account.CreatedById, Account.CreatedDate, Account.CustomerPriority__c,
Account.Name, Account.NumberOfEmployees, Account.NumberofLocations__c, Account.OwnerId, Account.Ownership, 
 Account.Site, Account.SLA__c, Account.SLAExpirationDate__c, Account.SLASerialNumber__c,
 Account.SystemModstamp, Account.TickerSymbol, Account.Tradestyle, Account.Type, Account.UpsellOpportunity__c, 
   (select Sequence__c, Action__c from AcmeCo_Account_c__r where Processed__c = false and IDM__c = 'TEST1' ) 
from Account where Account.Id in (select Link__c from AcmeCo_Account__c where IDM__c = 'TEST1' and Processed__c = false) 

But it give an error:
(select Sequence__c, Action__c from AcmeCo_Account_c__r where Processed__c
                                    ^
ERROR at Row:17:Column:40
Didn't understand relationship 'AcmeCo_Account_c__r' in FROM part of query call. 
If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. 

The custom table is created . 
How can i avoid this or correct the query ?

thanks

 
I need to sign up a new Organization in Salesforce and do some development in .Net. But i want to know when a user signs up are they given a Production instance and SanbBox instance by default ? or is Production instance by default always given and the user has to set up a SandBox for testing ?
If i have lets say a Production , SandBox and Developer Edition in Salesforce. Is there a way I can login to one , probably Production and retrieve all instances registered to the Organisation. So logging into Production I can make some sort of ap[i call or apex call that will give me all instances assocaiated to this Organisation. (a link between Prod , Sandbox and Developer)
There is a rest call as follows;
GET /services/data/v40.0/tooling/query/?q=Select+id,SandboxName+from+SandboxInfo
But i am not using rest at the moment , only Soap , can i use an equivalent Soap call ?


Thanks