Salesforce App follow stopped working - salesforce

My company has an app that they got off of the app exchange(Note: before I started) that allowed you to follow or unfollow large number of cases/accounts/opportunities etc in salesforce.com. Supposedly it worked before and now it isn't working. I need an idea of what is wrong with the code for each button. If I can't fix them, any ideas for a replacement app? The app is no longer on the app exchange any more.
here's the code for the follow button:
{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")}
//EDIT THE FOLLOWING LINE TO ALTER THE CODE FOR OTHER OBJECTS. USE THE PICKLISTS ABOVE TO SELECT FIELD TYPE = $ObjectType AND THE OBJECT NAME THEN REPLACE "$ObjectType.Case" WITH YOUR NEW OBJECT NAME
var records = {!GETRECORDIDS( $ObjectType.Case)};
function LBox() {
var box = new parent.SimpleDialog("steve"+Math.random(), true);
parent.box = box;`
box.setTitle("Follow Records");
box.createDialog();
box.setWidth(220);
box.setContentInnerHTML("<img src='/img/loading32.gif' alt='' /> Running");
box.setupDefaultButtons();`
box.show();
}
function CBox(){
box.setContentInnerHTML("You are now following "+follow_count+" records<br /><br />Close");
}
if (records[0] == null) {
alert("Please select at least one record.");
}
else {
var follow_count = 0;
LBox();
for (var i = 0; i < records.length; i++){
var fol=new sforce.SObject("EntitySubscription");
fol.ParentId = records[i];
fol.SubscriberId = '{!User.Id}';
try{
sforce.connection.create([fol]);
follow_count++;
}
catch(e){
alert(e);
}
}
CBox();
}
here's the unfollow button:
{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")}
// EDIT THE FOLLOWING LINE TO ALTER THE CODE FOR OTHER OBJECTS. USE THE PICKLISTS ABOVE TO SELECT FIELD TYPE = $ObjectType AND THE OBJECT NAME THEN REPLACE "$ObjectType.Case" WITH YOUR NEW OBJECT NAME
var records = {!GETRECORDIDS( $ObjectType.Case)};
// display running message popup
function LBox() {
var box = new parent.SimpleDialog("steve"+Math.random(), true);
parent.box = box;`
box.setTitle("Unfollow Records");
box.createDialog();
box.setWidth(220);
box.setContentInnerHTML("<img src='/img/loading32.gif' alt='' /> Running");
box.setupDefaultButtons();
box.show();
}
// display output message
function CBox(){
if (unfollow_count < records.length)
box.setContentInnerHTML("You have now unfollowed "+unfollow_count+" records. You were not following the other selected records. <br /><br />Close");
else
box.setContentInnerHTML("You have now unfollowed "+unfollow_count+" records. <br /><br />Close");
}
if (records[0] == null) {
alert("Please select at least one record.");
}
else {
var unfollow_count = 0;`
LBox();
try {
// find following records
var searchstring = "SELECT Id FROM EntitySubscription WHERE (ParentId IN (";
for (var i = 0; i < records.length - 1; i++) {
searchstring += "'" + records[i] + "',";
}
searchstring += "'" + records[records.length - 1] + "') AND SubscriberId ='{!User.Id}')";
var resultRecords = sforce.connection.query(searchstring).getArray("records");
// delete following records
var recordIds = [];
for (var i = 0; i < resultRecords.length; i++) {
recordIds.push(resultRecords[i].Id);
unfollow_count++;
}
sforce.connection.deleteIds(recordIds);
} catch(e) {
alert(e);
}
CBox();
}
The first error message has to do with permissions, I don't get this error because I have admin rights, the second error is only on the account tab's button. I'm more worried about the permissions problem, is there anything there about permissions. Any help is great!

I think the issue is a throttle in SFDC, you are limited to following only a certain number of records per user. If this app was designed as you described to mass-follow records, it's possible your hitting that throttle, which is kind of the impression I get from the error your co-worker is receiving about at most 1000, also if it worked before, it would make sense that you have maxed out a limit for the org/user

Queries on EntitySubscription by users who aren't system admins must contain a LIMIT. If you change the query code in the button to the following it should work:
// find following records
var searchstring = "SELECT Id FROM EntitySubscription WHERE (ParentId IN (";
for (var i = 0; i < records.length - 1; i++) {
searchstring += "'" + records[i] + "',";
}
searchstring += "'" + records[records.length - 1] + "') AND SubscriberId ='{!User.Id}') LIMIT 1000";

Related

script & sheet timing out when trying to print large arrays in google script

Background
I have a function that makes a REST API call using UrlFetchApp in Google Scripts.
But the response only returns 2000 records at a time. If there are more records, there is, in the response, a key called nextRecordsUrl, which contains the endpoint and parameters needed to get the next batch of records.
I use a do...while loop to iterate through, pushing the records into a predesignated array, make the next api call. And when it reaches the last batch of records, it exists the do-while loop, then prints (not sure if that's the right term here) the entire to a Google Sheet.
The code
It looks like this:
function getCampaignAssociations() {
clearPage('CampaignAssociations');
var query = '?q=select+CampaignMember.FirstName,CampaignMember.LastName,CampaignMember.LeadId,CampaignMember.ContactId,CampaignMember.Name,CampaignMember.CampaignId,CampaignMember.SystemModstamp,CampaignMember.Email+from+CampaignMember+ORDER+BY+Email ASC,SystemModstamp+ASC';
try {
var arrCampAssociation = getInfoByQuery(query);
if (arrCampAssociation.records.length < 1) {
throw 'there are no records in this query';
}
var campaignAssoc = [];
do {
Logger.log(arrCampAssociation.nextRecordsUrl);
for (var i in arrCampAssociation.records) {
let data = arrCampAssociation.records[i];
let createDate = Utilities.formatDate(new Date(data.SystemModstamp), "GMT", "dd-MM-YYYY");
let a1 = "$A" + (parseInt(i) + 2);
let nameFormula = '=IFERROR(INDEX(Campaigns,MATCH(' + a1 + ',Campaigns!$A$2:A,0),2),"")';
let typeFormula = '=IFERROR(INDEX(Campaigns,MATCH(' + a1 + ',Campaigns!$A$2:A,0),3),"")';
campaignAssoc.push([data.CampaignId, nameFormula, typeFormula, data.Email, data.FirstName, data.LastName, data.LeadId, data.ContactId, createDate]);
}
var arrCampAssociation = getQueryWithFullEndPoint(arrCampAssociation.nextRecordsUrl);
} while (arrCampAssociation.nextRecordsUrl != null && arrCampAssociation.nextRecordsUrl != undefined);
let endRow = campAssocSheet.getLastRow(),
endColumn = campAssocSheet.getLastColumn(),
nameRange = campAssocSheet.getRange(2, 1, endRow, endColumn),
destRange = campAssocSheet.getRange(2, 1, campaignAssoc.length, campaignAssoc[0].length);
destRange.setValues(campaignAssoc);
sheet.setNamedRange('CampaignAssociation', nameRange);
} catch (e) {
Logger.log(e);
Logger.log(arrCampAssociation);
Logger.log(campaignAssoc);
Logger.log(i);
}
}
Issue
Everything works nicely until it comes to printing the array campaignAssoc to the Google Sheet.
See screenshot of the log below. It contains the endpoint for the next both. Notice the timestamp between the earlier logs and the timestamp between the last endPoint and the log where it timed out.
It seems to me that the issue is that when it comes to the printing of the data, it's having issues. If that's the case, have I overloaded the array? There are a total of over 36400 records.
Second attempt
I've tried resetting the array at each loop and printing the array to Google sheet. This is just 2000 records at each attempt and I've definitely done more rows at 1 time, but that didn't help.
Here's the code for that attempt.
function getCampaignAssociations() {
clearPage('CampaignAssociations');
var query = '?q=select+CampaignMember.FirstName,CampaignMember.LastName,CampaignMember.LeadId,CampaignMember.ContactId,CampaignMember.Name,CampaignMember.CampaignId,CampaignMember.SystemModstamp,CampaignMember.Email+from+CampaignMember+ORDER+BY+Email ASC,SystemModstamp+ASC';
try {
var arrCampAssociation = getInfoByQuery(query);
if (arrCampAssociation.records.length < 1) {
throw 'there are no records in this query';
}
do {
Logger.log(arrCampAssociation.nextRecordsUrl);
var campaignAssoc = [];
for (var i in arrCampAssociation.records) {
let data = arrCampAssociation.records[i];
let createDate = Utilities.formatDate(new Date(data.SystemModstamp), "GMT", "dd-MM-YYYY");
let a1 = "$A" + (parseInt(i) + 2);
let nameFormula = '=IFERROR(INDEX(Campaigns,MATCH(' + a1 + ',Campaigns!$A$2:A,0),2),"")';
let typeFormula = '=IFERROR(INDEX(Campaigns,MATCH(' + a1 + ',Campaigns!$A$2:A,0),3),"")';
campaignAssoc.push([data.CampaignId, nameFormula, typeFormula, data.Email, data.FirstName, data.LastName, data.LeadId, data.ContactId, createDate]);
}
let lastRow = campAssocSheet.getLastRow()+1;
campAssocSheet.getRange(lastRow,1,campaignAssoc.length,campaignAssoc[0].length).setValues(campaignAssoc);
var arrCampAssociation = getQueryWithFullEndPoint(arrCampAssociation.nextRecordsUrl);
} while (arrCampAssociation.nextRecordsUrl != null && arrCampAssociation.nextRecordsUrl != undefined);
let endRow = campAssocSheet.getLastRow(),
endColumn = campAssocSheet.getLastColumn(),
nameRange = campAssocSheet.getRange(2, 1, endRow, endColumn);
sheet.setNamedRange('CampaignAssociation', nameRange);
} catch (e) {
Logger.log(e);
Logger.log(arrCampAssociation);
Logger.log(campaignAssoc);
Logger.log(i);
}
}
So here, each loop took a lot longer. Instead of being 1-2 seconds between each loop, it took 45 seconds to a minute between each and timed out after the 4th loop. See the log below:
How do I fix this?

How to skip the locator which does not exist in selenium webdriver?

I have around 50 rows in a page. But those items are in sequence.
The problem is when someone entered and deleted that table row. That id would not be there in page..
Example:
User added 1st record: id 101 added.
User added 2nd record: id 102 added
User added 3rd record: id 103 added.
If user deletes 2nd record, then two records would be there on the page but with id 101, 103.
I am trying to write that if that id is present then get the text else leave that in the for loop. I am getting only records till it found if that id is not found getting NoSuchElementException is displayed.
Please correct the code. But i want to the solution that if that id not exist, skip and run the else part.
for (int i = counterstart; i <= counterend; i++) {
if(driver.findElement(By.xpath("//*[#id='" + i + "']/a")).isDisplayed()){
System.out.println(i+" is present");
String Projects = driver.findElement(By.xpath("//*[#id='" + i + "']/a")).getText();
System.out.println(Projects);
} else{
System.out.println(i+" is NOT present");
}
}
The exception that I get:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //*[#id='7593']/a (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 503 milliseconds
Try this method isPresent instead of isDisplayed.
public boolean isPresent(WebElement e) {
boolean flag = true;
try {
e.isDisplayed();
flag = true;
}
catch (Exception e) {
flag = false;
}
return flag;
}
How about this:
for (int i = counterstart; i <= counterend; i++) {
WebElement element;
try{
element = driver.findElement(By.xpath("//*[#id='" + i + "']/a"));
}catch(NoSuchElementException n)
{
element = null;
}
if(element !=null){
System.out.println(i+" is present");
String Projects = driver.findElement(By.xpath("//*[#id='" + i + "']/a")).getText();
System.out.println(Projects);
}else{
System.out.println(i+" is NOT present");
}
}
Find all the parent of all the elements you want to get the text from and use it to drill down, this way you won't get the exception
Assuming the html looks like this
<div id="parent">
<div id="11">
<a>text</a>
</div>
<div id="12">
<a>text</a>
</div>
<div id="13">
<a>text</a>
</div>
</div>
You can do this
// get all the elements with id
List<WebElement> ids = driver.findElements(By.cssSelector("#parent > div"));
// get all the texts using the id elements
for (WebElement id :ids) {
String projects = id.findElement(By.tagName("a")).getText();
System.out.println(projects);
}

Get appointments from all Outlook calendars

I'm trying to read appointments from Outlook calendar using ExchangeServiceBinding but my solution takes appointments only from "default" outlook calendar and don't read from "sub calendars/custom calendars". Do you know how to define rest of the calendars or do you know better solution which contains all calendars?
Critical part is that solution shouldn't contain MAPI because of next use in web service.
My current code:
private static List<List<string>> ReadCalendarEvents(string email)
{
List<List<string>> calendarEvents = new List<List<string>>();
// Specify the request version.
esb.RequestServerVersionValue = new RequestServerVersion();
esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007;
// Form the FindItem request.
FindItemType findItemRequest = new FindItemType();
CalendarViewType calendarView = new CalendarViewType();
calendarView.StartDate = DateTime.Now.AddDays(-7);
calendarView.EndDate = DateTime.Now.AddDays(200);
calendarView.MaxEntriesReturned = 1000;
calendarView.MaxEntriesReturnedSpecified = true;
findItemRequest.Item = calendarView;
// Define which item properties are returned in the response.
ItemResponseShapeType itemProperties = new ItemResponseShapeType();
// Use the Default shape for the response.
//itemProperties.BaseShape = DefaultShapeNamesType.IdOnly;
itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;
findItemRequest.ItemShape = itemProperties;
DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
folderIDArray[0] = new DistinguishedFolderIdType();
folderIDArray[0].Id = DistinguishedFolderIdNameType.calendar;
//
folderIDArray[0].Mailbox = new EmailAddressType();
folderIDArray[0].Mailbox.EmailAddress = email;
findItemRequest.ParentFolderIds = folderIDArray;
// Define the traversal type.
findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
try
{
// Send the FindItem request and get the response.
FindItemResponseType findItemResponse = esb.FindItem(findItemRequest);
// Access the response message.
ArrayOfResponseMessagesType responseMessages = findItemResponse.ResponseMessages;
ResponseMessageType[] rmta = responseMessages.Items;
int folderNumber = 0;
foreach (ResponseMessageType rmt in rmta)
{
// One FindItemResponseMessageType per folder searched.
FindItemResponseMessageType firmt = rmt as FindItemResponseMessageType;
if (firmt.RootFolder == null)
continue;
FindItemParentType fipt = firmt.RootFolder;
object obj = fipt.Item;
// FindItem contains an array of items.
if (obj is ArrayOfRealItemsType)
{
ArrayOfRealItemsType items =
(obj as ArrayOfRealItemsType);
if (items.Items == null)
{
folderNumber++;
}
else
{
foreach (ItemType it in items.Items)
{
if (it is CalendarItemType)
{
CalendarItemType cal = (CalendarItemType)it;
List<string> ce = new List<string>();
ce.Add(cal.Location);
ce.Add(cal.Start.ToShortDateString() + " " + cal.Start.ToShortTimeString());
ce.Add(cal.End.ToShortDateString() + " " + cal.End.ToShortTimeString());
ce.Add(cal.Subject);
if (cal.Organizer != null)
{
ce.Add(cal.Organizer.Item.Name);
}
calendarEvents.Add(ce);
Console.WriteLine(cal.Subject + " " + cal.Start.ToShortDateString() + " " + cal.Start.ToShortTimeString() + " " + cal.Location);
}
}
folderNumber++;
}
}
}
}
catch (Exception e)
{
throw;
}
finally
{
}
return calendarEvents;
}
In EWS you need to query one folder at a time, for non default folders you will first need to find the FolderId before you can then query the appointments (or items) within a Folder. To find all the Calendar folders in a Mailbox you need to use the FindFolder operation and create a restriction to limit the result to folder with a FolderClass of IPF.Appointment eg
// Create the request and specify the travesal type.
FindFolderType findFolderRequest = new FindFolderType();
findFolderRequest.Traversal = FolderQueryTraversalType.Deep;
// Define the properties that are returned in the response.
FolderResponseShapeType responseShape = new FolderResponseShapeType();
responseShape.BaseShape = DefaultShapeNamesType.Default;
findFolderRequest.FolderShape = responseShape;
// Identify which folders to search.
DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
folderIDArray[0] = new DistinguishedFolderIdType();
folderIDArray[0].Id = DistinguishedFolderIdNameType.msgfolderroot;
IsEqualToType iet = new IsEqualToType();
PathToUnindexedFieldType FolderClass = new PathToUnindexedFieldType();
FolderClass.FieldURI = UnindexedFieldURIType.folderFolderClass;
iet.Item = FolderClass;
FieldURIOrConstantType constantType = new FieldURIOrConstantType();
ConstantValueType constantValueType = new ConstantValueType();
constantValueType.Value = "IPF.Appointment";
constantType.Item = constantValueType;
iet.FieldURIOrConstant = constantType;
// Add the folders to search to the request.
RestrictionType restriction = new RestrictionType();
restriction.Item = iet;
findFolderRequest.Restriction = restriction;
findFolderRequest.ParentFolderIds = folderIDArray;
try
{
// Send the request and get the response.
FindFolderResponseType findFolderResponse = esb.FindFolder(findFolderRequest);
// Get the response messages.
ResponseMessageType[] rmta = findFolderResponse.ResponseMessages.Items;
foreach (ResponseMessageType rmt in rmta)
{
// Cast to the correct response message type.
if (((FindFolderResponseMessageType)rmt).ResponseClass == ResponseClassType.Success) {
foreach (FolderType folder in ((FindFolderResponseMessageType)rmt).RootFolder.Folders) {
Console.WriteLine(folder.DisplayName);
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
You also might want to look at using the EWS Managed API which will save you greatly time and the amount of code you need to write
Cheers
Glen

context.SaveChanges() not persisting data in database

Im working on a MVC app.
When I call context.SaveChanges to update a specific records. The update is not registered in the database. I do not get any runtime error either. All in notice is that my Records is not updated. I still see the same values. Insert Functionality work Perfectly.
enter code here
public Admission Update(int stuid){
VDData.VidyaDaanEntities context = new VDData.VidyaDaanEntities();
VDData.Student_Master studentmaster = new VDData.Student_Master();
studentmaster.Student_ID = stuid;
studentmaster.Student_First_Name = this.FirstName;
studentmaster.Student_Middle_Name = this.MiddleName;
studentmaster.Student_Last_Name = this.LastName;
studentmaster.Student_Address_1 = this.Address;
studentmaster.Student_Address_2 = this.Address2;
studentmaster.Student_City = this.City;
studentmaster.Student_State = this.State;
studentmaster.Student_Pin_Code = this.Pincode;
context.SaveChanges(); // here it wont give any kind of error. it runs sucessfully. }
First get the entity you are going to update:
var entity = obj.GetEntity(id);
entity.col1 = "value";
context.SaveChanges(entity);
hope this will help.
It seems like you want to update, so your code should be
VDData.Student_Master studentmaster = context.Student_Masters.Single(p=>p.Student_ID == stuid);
And you should not change the Student_ID if it is the primary key.
public Admission Update(int stuid){
VDData.VidyaDaanEntities context = new VDData.VidyaDaanEntities();
//VDData.Student_Master studentmaster = new VDData.Student_Master();
//REPLACE WITH
VDData.Student_Master studentmaster = context.Student_Masters.Where(p=>p.Student_ID == stuid);
studentmaster.Student_ID = stuid;
studentmaster.Student_First_Name = this.FirstName;
studentmaster.Student_Middle_Name = this.MiddleName;
studentmaster.Student_Last_Name = this.LastName;
studentmaster.Student_Address_1 = this.Address;
studentmaster.Student_Address_2 = this.Address2;
studentmaster.Student_City = this.City;
studentmaster.Student_State = this.State;
studentmaster.Student_Pin_Code = this.Pincode;
context.SaveChanges();
Before
context.SaveChanges();
You need to call this
context.Student_Masters.Add(studentmaster );
Edit: introduce Abstraction to your Context class and Create a method in your context class like below, then you can call it whenever you want to create or update your objects.
public void SaveStudent_Master(Student_Master studentmaster)
{
using (var context = new VDData.VidyaDaanEntities())
{
if (studentmaster.Student_ID == 0)
{
context.Student_Masters.Add(studentmaster);
}
else if (studentmaster.Student_ID > 0)
{
//This Updates N-Level deep Object grapgh
//This is important for Updates
var currentStudent_Master = context.Student_Masters
.Single(s => s.Student_ID == studentmaster.Student_ID );
context.Entry(currentStudent_Master ).CurrentValues.SetValues(studentmaster);
}
context.SaveChanges();
}
Then in your Controller replace context.SaveChanges(); with _context.SaveStudent_Master(studentmaster);

Distriqt AIR Local Notification Ane - Delete old Notifications

we try to implement the nice local notifications extension of distriqt.
With the deactivate event new notifications were set:
notification.id = int(Math.random()*100);
notification.tickerText = _asde + " asdasd!";
notification.title = _asde + " asd!";
notification.body = "asd!";
notification.iconType = NotificationIconType.APPLICATION;
notification.count = 0;
notification.repeatInterval = 0;
notification.vibrate = false;
notification.playSound = true;
notification.soundName = "assets/sounds/notification.mp3";
notification.delay = secondsToDeath;
notification.data = "Some notification data to attach "+notification.id;
try
{
Notifications.service.notify( notification.id, notification );
_count ++;
Notifications.service.setBadgeNumber( _count );
}
catch (e:Error)
{
}
If the user clicks on the app and deactivates it again, new notifications were set.
The old notifications are still available and are displayed but we want the old to be deleted.
We haven't found a method to unregister the old notifications.
Any idea?
private static const DEACTIVATE_NOTIFICATION_ID_4 : int = 4;
Is declared.
if(_GoodA == true){
setSpielenFertigDate.time = 2400000*(1-_aktuellerFreudeWert/_maximalerFreudeWert);
var secondsToSpielenFertig:int = int((setSpielenFertigDate.time)/ 1000);
trace("halloe" + _fernseherAn.toString());
notification4.id = DEACTIVATE_NOTIFICATION_ID_4;
notification4.tickerText = "He test it!";
notification4.title = "sdf is happy!";
notification4.body = "sdf test is on!";
notification4.iconType = NotificationIconType.APPLICATION;
notification4.count = 0;
notification4.repeatInterval = 0;
notification4.vibrate = false;
notification4.playSound = true;
notification4.soundName = "assets/sounds/notification.mp3";
notification4.delay = secondsToSpielenFertig;
notification4.data = "Some notification data to attach "+ notification4.id;
try
{
Notifications.service.notify( notification4.id, notification4 );
_count ++;
Notifications.service.setBadgeNumber( _count );
}
catch (e:Error)
{
}
}
else{
trace("halloe2" + _fernseherAn.toString());
setSpielenDate.time = 5100000*(_aktuellerFreudeWert/_maximalerFreudeWert);
var secondsToSpielen:int = int((setSpielenDate.time)/ 1000);
notification4.id = DEACTIVATE_NOTIFICATION_ID_4;
notification4.tickerText = "He tested it!";
notification4.title = "sdf is unhappy!";
notification4.body = "sdf test is off!";
notification4.iconType = NotificationIconType.APPLICATION;
notification4.count = 0;
notification4.repeatInterval = 0;
notification4.vibrate = false;
notification4.playSound = true;
notification4.soundName = "assets/sounds/notification.mp3";
//Sekunden bis Nachricht geschickt wird
notification4.delay = secondsToSpielen;
notification4.data = "Some notification data to attach "+notification4.id;
try
{
Notifications.service.notify( notification4.id, notification4 );
_count ++;
Notifications.service.setBadgeNumber( _count );
}
catch (e:Error)
{
}
}
If the deactivate event of the app is fired it traces the correct part of the if and else clause. But it won't update the body and title...
There are two ways to do this with our extension. Both involve tracking the ID of the notification.
The first is to track your last notification and "cancel" it from the notification area. To do this you need to store at least the ID of the last created notification. The part of the code that you're probably interested in is the cancel function, this removes a notification from the notification panel by specifying the id of the notification to remove.
Somewhere in your class declare a reference to the last notification:
private var _lastNotification : Notification;
Then in your deactivate handler:
var notification:Notification = new Notification();
notification.id = int(Math.random()*100);
notification.tickerText = "Deactivated";
notification.title = "TEST";
notification.body = "Application Deactivated";
if (_lastNotification != null)
Notifications.service.cancel( _lastNotification.id );
Notifications.service.notify( notification.id, notification );
// Set this to be the recent notification displayed
_lastNotification = notification;
The second option is to use a single notification id for all of your deactivate notifications. In this case you choose a constant ID to use for your notification and update the notification as required. The notification manager will not show an additional notification but simply update the one with the specified ID (or show it if it has been closed by the user).
private static const DEACTIVATE_NOTIFICATION_ID : int = 10;
var notification:Notification = new Notification();
notification.id = DEACTIVATE_NOTIFICATION_ID;
notification.tickerText = "Deactivated";
notification.title = "TEST";
notification.body = "Application Deactivated";
Notifications.service.notify( notification.id, notification );
Hope this helps!

Resources