Inefficient Formula

OK.My users have grown tired on my excuse “it works fine for me” - (takes less than 2 seconds).

For some reason my script below, which address’s a problem that we have and IBM have acknowledged, with the INetSendTo field, is taking a long, long time for some users.

Any tips to speed it up?

Last time I posted this for another issue people did not like it very much!

ViewName:=@ViewTitle ;

ViewNameT:=@Text(ViewName);

@If(ViewName!=“($Sent)”;

@Do(

@Prompt([Ok];“Sorry”;“You can only use this button from the Sent Items View. You are in the " + ViewNameT + " View. You will now be navigated to Sent Items, where you need to navigate to the email you wish to import.”);

@Command( [OpenView] ; “($Sent)” );

@Return(“”));

“”);

@If(INetSendTo!=“.”;“”;

@Do(

@SetField(“INetSendTo”; SendTo)));

@If(INetCopyTo!=“.”;“”;

@Do(

@SetField(“INetCopyTo”; CopyTo)));

FIELD SendTo:=SendTo;

n := 1;

@While(n <= @Elements(SendTo);

database := @Subset(@DbName; -1);

server := @Name([CN]; @Subset(@DbName; 1));

noteslookup:=@If(server=“”;

@DbLookup(“Notes”:“”; “”:NAMES.nsf;“People”;@Name([CN];SendTo[n]);“InternetAddress”);

@DbLookup(“Notes”:“”;“85255F7E:006405B0”;“($NamesFieldLookup)”; @Name([CN];SendTo[n]);“InternetAddress”));

GetFirstName:=@Left(SendTo[n];4);

FirstLetter:=@LowerCase(@Text(@Right(GetFirstName;1 )));

Surname:=@LowerCase(@RightBack(@Name([CN];SendTo[n]);" "));

@If(@Contains(SendTo[n];“>”);

@Set(“Trimmed”;@MiddleBack(SendTo[n]; “>” ; “<” ));

“”);

Addr821:=@If(@Contains(SendTo[n];“CN=”);

@If(!@IsError(noteslookup);

noteslookup;

@Prompt([OkCancelEdit]; “Sorry! We could not find the relevant email address,”; “Please enter the correct address in the box below. We have made a suggestion for you, which needs to be changed to the correct address”; “” + FirstLetter +Surname+ “@companyname.com”));

@Name([Address821];SendTo[n]));

ABSendTo:=@If(@Contains(Addr821;"@companyname.com");Addr821;INetSendTo[n]);

@If(@Contains(Addr821;"@companyname.com");

@Set(“tempvar”;tempvar + “;” + ABSendTo);

“”);

n := n + 1);

@If(@Contains(Addr821;"@companyname.com");

@SetField(“INetSendTo”;@Explode(tempvar));

“”);

@If(Trimmed!=“”;

@SetField(“INetSendTo”;@Explode(Trimmed));“”);

FIELD SaveOptions:=@DeleteField;

@Command([FileSave]);

@Prompt([Ok];“Thank You " + @Text(@Left(@Name([CN];@UserName);” ")) + “.”; “Your email is now ready to be imported into Siebel.”)

Subject: Inefficient Formula…

what is it that takes a long time? Is it when switching to the $Sent view? If so, nothing is wrong with the code. If you are already in the $Sent view and it takes a long time, what is a long time defined as? 5 seconds, 30 seconds, 1 minute or more? Do you know at what point the code hangs? Possibly the lookups are quicker for you since you use the views more often?

Subject: RE: Inefficient Formula…

  1. We were already in the $Sent view.2) More than 1 minute. We waited about 3-4 mins and it still didnt work so I cancelled it

  2. No - I don’t know when it hangs, but I am almost certain its the lookups which are slow/not working.

This is because, we added the person that the email was sent to to the Users Local Address Book. Then it worked very quickly.

So, I tried to use an @If statement so it doesn’t do the lookup if the person is external to the company (of course I thought that I had already built this logic in but it seems not).

So now the noteslookup looks more like this:

internal:=@If(@Contains(SendTo[n];“@CompanyName-Corporate:"@companyname.com");“Yes”;“No”);

@If(internal!=“Yes”;noteslookup=“”; noteslookup:=@If(server=“”;

@DbLookup(“Notes”:“”; “”:NAMES.nsf;“People”;@Name([CN];SendTo[n]);“InternetAddress”);

@DbLookup(“Notes”:“”;“85255F7E:006405B0”;“($NamesFieldLookup)”; @Name([CN];SendTo[n]);“InternetAddress”)));

So maybe it will at least be quicker for emails sent to external people - which will be the vast majority of cases…