Wednesday, January 30, 2013

Mass Delete in Salesforce

Mass Deleting of Custom Object Data in Force.com (Salesforce) made easy.

Executing a small piece of Apex Code using Developer Console is the easiest way to get rid of Mass Data from your Custom Objects.

Execute the following APEX Code using Developer Console.

App Setup >> Tools >> Developer Console is the menu to access Dev Console, if you want to.





And, here is the APEX code to execute.


String[] ss = new String[]{'ABC-0000000005', 'ABC-0000000007'};

List existing = [SELECT Id From My_Custom_Object__c WHERE Name IN :ss];

delete existing;

As you can see, WHERE clause of the SOQL can be customized at your will.

Good Luck.

Thursday, December 20, 2012

Scrambling VARCHAR / Text Data in SQL Server

Everyone wants to scramble their production data before they give it out for testing.

I also had the same requirement.

However, I was required to do something more.

Scrambled Data should pass some regular expression validations.

For example, Name should still be First_Name Last_Name, Email Address should look like a valid email address, etc.

Like Jack Sparrow to become Dchv Dkiokmd

And, Jack.Sparrow@pirate27.biz to become Ninj.Sdkpiqy@wywmky53.kdd.

Here is what I have done.


-------------------------------------------------

--A view to give you Random Values

CREATE VIEW dbo.random(value) AS SELECT RAND();

GO
-------------------------------------------------

--Randomization Procedure

CREATE FUNCTION dbo.fnRandomizedText (
@OldValue AS VARCHAR(MAX)
)RETURNS VARCHAR(MAX)

BEGIN

  DECLARE @NewValue AS VARCHAR(MAX)
  DECLARE @nCount AS INT
  DECLARE @cCurrent AS CHAR(1)
  DECLARE @cScrambled AS CHAR(1)
  DECLARE @Random AS REAL
 
  SET @NewValue = ''
  SET @nCount = 0
   WHILE (@nCount <= LEN(@OldValue))
  BEGIN
    SELECT @Random = value FROM random
    SET @cCurrent = SUBSTRING(@OldValue, @nCount, 1)
     IF ASCII(@cCurrent) BETWEEN ASCII('a') AND ASCII('z')
       SET @cScrambled = CHAR(ROUND(((ASCII('z') - ASCII('a') - 1) * @Random + ASCII('a')), 0))
    ELSE IF ASCII(@cCurrent) BETWEEN ASCII('A') AND ASCII('Z')
       SET @cScrambled = CHAR(ROUND(((ASCII('Z') - ASCII('A') - 1) * @Random + ASCII('A')), 0))
    ELSE IF ASCII(@cCurrent) BETWEEN ASCII('0') AND ASCII('9')
       SET @cScrambled = CHAR(ROUND(((ASCII('9') - ASCII('0') - 1) * @Random + ASCII('0')), 0))
    ELSE
       SET @cScrambled = @cCurrent

    SET @NewValue = @NewValue + @cScrambled
    SET @nCount = @nCount + 1

  END
   RETURN LTRIM(RTRIM(@NewValue))
END
GO
 
-------------------------------------------------

With this Function, you can update your tables just like this.


UPDATE my_Users_table SET UserName = dbo.fnRandomizedText(UserName), LoweredUserName = dbo.fnRandomizedText(LoweredUserName)

Thursday, September 24, 2009

Error Nr. 1045 Access denied for user 'root'@'localhost' (using password: YES)

Error Nr. 1045 Access denied for user 'root'@'localhost' (using password: YES) in MySQL installation (Windows).
Are you getting this error when you install MySQL in Windows XP box?
And the Fourth step (Security Settings) in the Execution of Config wizard gives trouble?

Don't bother to reset root password, etc, etc.. which doesn't work for most of us.
Just delete the instance using "MySQL Server Instance Config Wizard" and recreate it.
Just be careful in supplying the password.
I would say, type the password in notepad and copy paste it.

Good Luck!!!

Thursday, May 15, 2008

PHPFileNavigator, Files not displayed



Files are not displayed in PHPFileNavigator?
Not able to download the files?
Or your root folder shows some date in 1969 or older?

Solution is simple.
In pfn_raices table, path and web field values should end with a '/'(slash) character.
Tree view may still show the files even if the path and web don't have a '/' in the end.
However, Thumbnail view will not show any, because it cannot interpret the path.

Tuesday, May 6, 2008

WAMP and IIS on the same Server.



How to have both WAMP and IIS web servers running in the same server together?

Two ways.

1. Same IP Address. Different Port number.
This is the easy way. Assign different port numbers in IIS and WAMP. They will work without any problem.

2. Same Port number. Different IP address.
Things will get tricky when you have to use the same port number.
For example in my case, I have www.domain-a.com linked t0 192.168.1.27:80 and www.domain-b.com linked to 192.168.1.28:80.
Domain-a is a .NET 2.0 based website running on IIS. Domain-b is Joomla running on WAMP.

Here you go.

Step1. Stop the HTTP service
net stop http in command prompt.
If this command prompts any question about stopping some services, say yes.

Step2. Edit the registry. (You better backup the registry before playing around with it ;))
i. Click Start, click Run, type regedit, and then click OK.
ii. In Registry Editor, locate the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\ListenOnlyList
If you don’t find this, no harm. Create one multi-string value in the same name.
iii. Make sure it has only the IP addresses that you want your IIS to listen. In my case, 192.168.1.27.
One IP address per line.
Guess what? IIS doesn’t know about 192.168.1.28 anymore. :)

Step3. Start the HTTP Service.
net start http in command prompt.
You have to start couple of services in MMC as well. (HTTP SSL and World Wide Web Publishing Service)
Now, you can run both the web servers together on same port number. Of course, different IP addresses.

192.168.1.27:80 isIIS Website
192.168.1.28:80 is WAMP website.

In fact, 192.168.1.28 is sole property of WAMP now. IIS can’t use this IP address with any port number.

Friday, February 15, 2008

How to access Parent Form Methods from Child Form in .NET C#?



/* How to access Parent Form Methods from Child Form in .NET C#?

There may be 101 ways.

Simplest way I know is to create a Public Static variable to Carry your Parent form. :)

Here it is. */

//Add this code in the parent form


//declare the public static variable.
public static Parent ParentInstance;


//before you call the ChildInstance.Show(), assign the parent form to ur variable.

ParentInstance = this;
ChildInstance.Show();


//Add this code piece in the Child form

Parent.ParentInstance.YourMethodName();

/* Beauty is you don't need to declare your method as Static, which is not possible in most of the occasions [when u access form controls in ur method]*/