Authored by Zishan Razzaq
Showing posts with label SOQL. Show all posts
Showing posts with label SOQL. Show all posts

Thursday, November 29, 2012

How to use 'NOT LIKE' in SALESFORCE SOQL

Hi everyone:
    Business Scenario:
        They would like something update where a field on the record is NOT LIKE "adviser." Or in simplest terms does not contain "Adviser".

Solution for developers in APEX:

APEX will not allow someone to write a simple query such as:
SELECT Name From ABC where id=:Ownerid and Name NOT Like '%adviser%';

So solution is simple:
SELECT NAME From ABC where id=:Ownerid and (NOT Name Like  '%adviser%');

If you are utilizing GROUP By statements here is an example of one:


 AggregateResult[] groupedResults = 
         [SELECT Ownerid,Count(Id) ce 
         FROM Opportunity Where 
         Withdrawn__c = True 
         AND StageName = 'Closed Won' 
         AND Withdrawal_Status__c ='Withdrawn' 
         AND Withdrawn_Date__c = THIS_MONTH  
         AND Ownerid=:id 
         AND (NOT Name Like '%COMP%')
         GROUP BY Ownerid];  

Hope this Helps.
Thanks
Zishan



Thursday, February 23, 2012

Change Password via Developer Console in Salesforce without resetting password

Scenario:
      We need to reset a password or change the password on an user utilizing a 3rd party app in salesforce. This user is there for the app only and not really a physical user in the instance. The email for this user is a person who has left the company or is on vacation but you need the app to work.

Solution:
    You can do this 2 ways:
  1. Change the Email of the user in question
  2. Click on Generate Password and click save.
But lets say you can not change the Email of the user because you should not be the owner of the app or you are not part of the app as an admin. Here is where you change using Developer Console.

Go to Setup and Drop it down to Developer Console or sometimes called the System Log




Within the "Logs" tab you will see a button called "Execute".


Click on the text box or white space next to it.

It shall open up another window which is titled "Enter Apex Code"

Place in the following SOQL query:
User usr = [select Id from User where username='appuser@myzc.com'];
System.setPassword(usr.Id,'welcome1234');

Then click on Execute.
It should bring up a success window and you should be good to go.
Now you may need to log in and make sure everything is ok.

Hope this helps... I am not responsible for anyone utilizing this method... It can be a risk... I would check before you do this task.
Thanks
Zishan R.


Watch Me Fight 
Join My Facebook on Cage Assassin Fight Gear 
Like my fan page Cage Assassin Fight Gear 

Thursday, November 20, 2008

Tips and Tricks About AJAX TOOLS in Salesforce.com

Hi all:
Today, I want to give tips and tricks about AJAX TOOLS in salesforce.com. But you need a couple things first:
  • If you have an salesforce.com org set up then download the ajax toolkit .
  • Click on Get it Now.
  • Go to the process, it will ask where would you like to place it, using your developer account, company's or sandbox username and password.
  • Once all of the steps are done and executed onto the org you decided.
  • This will create an app onto your org called AJAX TOOLS. Look at Picture

  • The best place to run AJAX is in Mozilla Firefox (If you do not have Mozilla then download here). With IE it does not work properly.
  • Now once we are in AJAX, Click on Start Ajax Tools - This will open up a new window and first thing you will see is all of your S-Controls and Underneath that your Apex Classes, and Visual Force Pages.
  • You will see many icons on top going from Left to Right Across. See Picture Below
  • Save, Run, New, Backup and Config On the Left hand side of the Menu - Is used to save your S-Controls, Apex Classes
  • On the Right hand Side These are different set of menus that open up a new world.
  • Shell:
  1. You Can place your Javascript code to see if it runs correctly
  2. Can place in APEX Code, SOSL Statement or your SOQL statement
  3. To Make it run just hit enter...
  • Samples:
  1. Cool way to learn Javascript and correct SOQL Statements.
  • Explorer:
  1. This is the best tool of them all on this AJAX TOOLKIT.
  2. One can create queries and relationships just by selecting tables fields from the Parent Table.
  3. For example, Dropdown Account Where it states SObject.
  4. Next you will see all the fields come up PLUS all the relationship Tables that go along with the Account. AMAZING.
  5. You can do many things with the query statement you produce out of here.
  6. You can create your S-Control and then make the tweeqs that you need to make it work. All you have to do is click on Generate Sample. This will generate the code needed for your S-Control on that object. See Picture Below


I hope this help anyone out... Let me know...
Thanks
View my Other Blogs:
VisualForce Made Easy

Salesforce Data Migration Made Easy