• Bogdan Pascu
  • NEWBIE
  • 40 Points
  • Member since 2014
  • System Administrator
  • First Mallorca

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 18
    Replies
Hi everyone 

I would appreciate if anyone can help me with transforming the following trigger in to an apex batch 

trigger ListingRankingManagementTrigger on pba__Listing__c (after insert, after update) {
  
  
    // To avoid exceeding governor limits,
   // use a float to reorder and have an unattended process (batch) pass it to integers again
  
    List<pba__Listing__c> listings = Trigger.new;

    Map<Id, pba__Listing__c> oldListings = null;
    if (!Trigger.isInsert) {
      oldListings = Trigger.oldMap;
    }

    for (pba__Listing__c listing : listings) {

      boolean doMove = true;
      integer addFactor = 0;

     / * If we move the ranking we have to locate the listing that had the new ranking before and - If the new ranking is lower than the old one, add one - If the new ranking is higher than the old one, subtract one
   * /
      
      if (!Trigger.isInsert) {
        pba__Listing__c oldListing = oldListings.get(listing.Id);
        doMove = (oldListing.Ranking__c != listing.Ranking__c );
        if (oldListing.Ranking__c == null || listing.Ranking__c < oldListing.Ranking__c) {
          addFactor = 1;
        } else {
          addFactor = -1;
        }
      } else {    
         // If it is an insert, it is as if the previous ranking was the highest
        addFactor = 1;
      }
      
      if (listing.Ranking__c == null) {
       // If ranking has not been included, we do not move
        doMove = false;
      }
      
      if (doMove) {
        List<pba__Listing__c> prevListings = [Select Id, Ranking__c from pba__Listing__c l where l.Ranking__c =:listing.Ranking__c AND l.id != :listing.id];
        if (prevListings.size()>0) {
          pba__Listing__c prevListing = prevListings.get(0);
         // We have the listing that was previously in our Ranking. We are going to insert it between us and the following ranking
          pba__Listing__c nextListing = null;
          if (addFactor > 0) {
            nextListing = [Select Ranking__c from pba__Listing__c l where l.Ranking__c > :listing.Ranking__c order by Ranking__c ASC LIMIT 1];
          } else {
            nextListing = [Select Ranking__c from pba__Listing__c l where l.Ranking__c < :listing.Ranking__c order by Ranking__c DESC LIMIT 1];
          }
          if (nextListing != null) {
            prevListing.Ranking__c = (prevListing.Ranking__c + nextListing.Ranking__c) / 2;
            update prevListing;
          }
          
        }
          
      }
    }
  

}
I have the following trigger and I would need some help in creating the test class. Any help will be appreciated. 
 
trigger listingLocationUpdate on pba__Listing__c (before insert, before update) {

    //Mantiene actualizado el picklist Location en base al lookup Location
    List<pba__Listing__c> listings = Trigger.new;
    Map<Id, pba__Listing__c> oldListings = null;
    if (!Trigger.isInsert) {
        oldListings = Trigger.oldMap;
    }

    for (pba__Listing__c listing : listings) {

        if (!Trigger.isInsert) {
            pba__Listing__c oldListing = oldListings.get(listing.Id);
            if (oldListing.Location__c == listing.Location__c) {
                continue;
            }
        }
        if (listing.Location__c == null) {
            listing.fm_Location__c = null;
            continue;
        }

        pba__Location__c l = [Select Name from pba__Location__c where Id =:listing.Location__c];
        if (l != null) {
            listing.fm_Location__c = l.Name;
        }

    }
}

 
Hello I would need some help in building a trigger on the Event object. I need to copy the value from a custom field "ClientFeedback__c" to a standard one on the same object: "Description". I am missing this part from the trigger. 
 
trigger showingWorkflowTrigger on Event (after insert, after update) {

        List<Event> events = Trigger.new;
        Map<Id, Event> oldEvents = null;
        if (Trigger.isUpdate) {
            oldEvents = Trigger.oldMap;
        }
        
        
        for (Event event : events) {
            
            RecordType rt = [Select Name FROM RecordType where Id=:event.RecordTypeId];
            
            if (rt.Name == 'Showing' && event.WhoId != null) {


}
                
                if (Trigger.isUpdate) {
                     Event oldEvent = oldEvents.get(event.Id);

 
Hello everyone

I have implemented the below lightning map compomnent in our org. The map id displayed properly but some options are not working. 

I have in the footer the button open in google map but it is not working. There is also a button to display the map in full screen the same is not working.  Also I would like to make the Satelite option as a default instead of the map. 

Any help from you would be appreciated. 

This is how my map is being displayed at the moment: 
User-added image
​​​​​​​

Here is the component: 
<aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes"
                access="global">

    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="dsRecordId" type="Id" />
    <aura:attribute name="sObject" type="SObject" />
    <aura:attribute name="titleField" type="String" default="Name" />
    <aura:attribute name="latField" type="String" default="pba__Latitude_pb__c" />
    <aura:attribute name="longField" type="String" default="pba__Longitude_pb__c" />
    <aura:attribute name="title" type="String" />
    <aura:attribute name="fields" type="String[]" default="['Id']" />
    <aura:attribute name="mapMarkers" type="Object[]" />
    <aura:attribute name="zoomLevel" type="Integer" default="16" />
    <aura:attribute name="showFooter" type="Boolean" />
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <force:recordData aura:id="service" 
                         recordId="{!v.dsRecordId}" 
                         targetFields="{!v.sObject}" 
                         fields="{!v.fields}"
                         recordUpdated="{!c.onRecordUpdated}" />
    
    <aura:handler event="ltng:selectSObject" action="{!c.recordChangeHandler}" />
    
    <lightning:card title="{!v.title}" iconName="custom:custom106">
        <lightning:buttonIcon onclick="{!c.fullScreen}" size="large" iconName="utility:expand" />
        <lightning:map 
                       mapMarkers="{!v.mapMarkers}" 
                       zoomLevel="{!v.zoomLevel}" />
        <footer class="slds-modal__footer">
        <button class="slds-button slds-button_brand">Open in Google Maps</button>
      </footer>
    </lightning:card>  

</aura:component>



here is the controller:
({
    doInit : function(component, event, helper) {
        component.set("v.fields", ["Id", component.get("v.latField"), component.get("v.longField"), component.get("v.titleField")]);
        var recordId = component.get("v.recordId");
        component.set("v.dsRecordId", recordId);
        helper.reloadRecord(component);
	},

  	recordChangeHandler : function(component, event, helper) {
        console.log('recordChangeHandler');
        var id = event.getParam("recordId");
        component.set("v.dsRecordId", id);
        helper.reloadRecord(component);
	},
    
    fullScreen : function(component) {
        component.set("v.fullScreen", true);
    
    },
    
    closeDialog : function(component) {
        component.set("v.fullScreen", false);
    
    },    

  	onRecordUpdated : function(component, event) {
        console.log('onRecordUpdated');
        var sObject = component.get("v.sObject");
        if (sObject) {
	        component.set("v.title", sObject[component.get("v.titleField")]);
            component.set("v.mapMarkers", [
                {
                    location: {
                        Latitude: sObject[component.get("v.latField")],
                        Longitude: sObject[component.get("v.longField")]
                    }
                }
            ]);
        }
    }
})

helper:
({
    reloadRecord : function(component) {
        var service = component.find("service");
        service.reloadRecord(false, function() {
            var sObject = component.get("v.sObject");
            component.set("v.mapMarkers", [
                {
                    location: {
                        Latitude: sObject[component.get("v.latField")],
                        Longitude: sObject[component.get("v.longField")]
                    }
                }
            ]);
        });
	}

})



 
Hello

I ahve the following controller and I get tghis error on line 27: Loop must iterate over collection: Id. Can someone help me on how to solve this pelase. 

public class LightningMapListingsController {

   @AuraEnabled(cacheable=true)
    
    public static List<ListingWrapper> getAllListings(){
        
        List<pba__Listing__c> listings = [SELECT Id, Name, pba__ListingPrice_pb__c, MonthlyRent__c,
                             pba__PropertyType__c, Listing_status__c, pba__Street_pb__c, pba__Address_pb__c, Location__c, 
                             pba__Latitude_pb__c, pba__Longitude_pb__c, pba__PostalCode_pb__c 
                             FROM pba__Listing__c ];
        
        
        List<ListingWrapper> result = new List<ListingWrapper>();
        //process the result in a wrapper format
        //which would be easy to pass to map attriutes in lightning component
        for(pba__Listing__c listing : listings){
            //Creating a listingWrapper object
            ListingWrapper listingWrap = new ListingWrapper();
            listingWrap.Name = listing.Name;
            listingWrap.Price = listing.pba__ListingPrice_pb__c;
            listingWrap.MonthlyRent = listing.MonthlyRent__c;
            listingWrap.PropertyType = listing.pba__PropertyType__c;
            listingWrap.Status = listing.Listing_status__c;
            
            
        List<ListingAddressWrapper> listingAddressList = new List<ListingAddressWrapper>();
            for(pba__Property__c  add : listing.pba__Property__c){
                ListingAddressWrapper listingAddress = new ListingAddressWrapper();
                listingAddress.icon = 'custom:custom31';
                listingAddress.title = listing.Name;
                //Creating a AddressWrapper object
                AddressWrapper addWrap = new AddressWrapper();
                addWrap.Latitude = add.pba__Latitude_pb__c;
                addWrap.Longitude = add.pba__Longitude_pb__c;
                addWrap.Street = add.pba__Street_pb__c; 
                addWrap.Address = add.pba__Address_pb__c; 
                addWrap.Location = add.Location__c;
                addWrap.PostalCode = add.pba__PostalCode_pb__c;
                listingAddress.location = addWrap;
                listingAddressList.add(listingAddress);
            }
            listingWrap.listingAddressList = listingAddressList;
            result.add(listingWrap);
        }
        return result;
    }
    
    /**
     * Main wrapper class which will hold listing properties
     * along with a list of ListingAddressWrapper class which will
     * hold multiple location of a listing
     * */
    public class ListingWrapper{
        @AuraEnabled public String Name;
        @AuraEnabled public String PropertyType;
        @AuraEnabled public String Status;
        @AuraEnabled public Decimal Price;
        @AuraEnabled public Decimal MonthlyRent;
        @AuraEnabled public List<ListingAddressWrapper> listingAddressList;
    }
    
    /**
     * ListingAddressWrapper class which will hold icon and title of marker
     * along with multiple locations
     * */
    public class ListingAddressWrapper{
        @AuraEnabled public String title;
        @AuraEnabled public String icon;
        @AuraEnabled public AddressWrapper location;
    }
    
    /**
     * AddressWrapper class to hold address properties
     * */
    public class AddressWrapper{
        @AuraEnabled public String Street;
        @AuraEnabled public String Address;
        @AuraEnabled public String Location;
        @AuraEnabled public String PostalCode;
        @AuraEnabled public String Latitude;
        @AuraEnabled public String Longitude;
    }

}     
I have the following trigger on a custom object. Basically it counts the nr of characters from a text filed and display the info in to a numeric filed. The trigger is working as expected when the object is being updated but it fails when you create a new one. 

trigger count_nr_of_characters_on_sales_description_es on pba__Property__c (before insert, before update){ 
for(pba__Property__c a: Trigger.new){ 
System.debug('Number of Characters for Description Field: ' + a.fm_web_Long_description_es__c.length()); 
a.Nr_of_characters_sales_description_es__c = a.fm_web_Long_description_en__c.length(); 

}
Hello 

Since Summer 18 release I have notice that the images are not loading in Salesforce: templates, formulas, etc and I always get this kind of error: 

Refused to load the image '<URL>' because it violates the following Content Security Policy directive: "img-src <URL> *.eu10.content.force.com:* 'self' data:".

This is one of the images that want to display in a template: <apex:image id="theImage" value="{!URLFOR($Resource.SignatureMallorcaOpen, 'Mallorca_open.png')}" width="437" height="215px" alt="Description of image here"/>


If you upload the file as a documenta and use the link it is working. It should work as well with Static Resources. 

Has anyone knoiw how to fix this? 
All images that are generated via formula fields or visualforce pages are shown as broken since summer 18 release. The preview is not working. 

User-added image

When you copy paste the url of the images in any browser the images are working fine.

this is an example: http://firstmallorca.force.com/static/resource/leadstatus/Lead.png

And this is the formula: 

IMAGE( 
CASE( Stage_fm__c, 
"Lead", "http://firstmallorca.force.com/static/resource/leadstatus/Lead.png", 
"Showing", "http://firstmallorca.force.com/static/resource/leadstatus/showing.png", 
"Offer", "http://firstmallorca.force.com/static/resource/leadstatus/Offer.png", 
"Closing", "http://firstmallorca.force.com/static/resource/leadstatus/Closings.png", 
"Owner", "http://firstmallorca.force.com/static/resource/leadstatus/Owner.png", 
"Tenant", "http://firstmallorca.force.com/static/resource/leadstatus/Tenant.png", 
"/s.gif"), 
"status color")

Everything was working fine until the summer 18 release. 

Has anyone else experience this?
Hi I have this formula which is working fine. Now I would like to include in the formula this line

IMAGE( IF( pba__SystemHasClosedClosing__c  = True , "http://firstmallorca.force.com/static/resource/listingstatus/Closing.png",""), "")

Can you please help me to onclude this line in to the formula. 

Also this picklist value shoul be condioned only if pba__SystemHasClosedClosing__c  = False

IMAGE( 
CASE( pba__Status__c , 
"In Acquisition", "http://firstmallorca.force.com/static/resource/listingstatus/Inpreparation.png", 
"In Preparation", "http://firstmallorca.force.com/static/resource/listingstatus/Inpreparation.png", 
"Active", "http://firstmallorca.force.com/static/resource/listingstatus/Active.png", 
"Reserved", "http://firstmallorca.force.com/static/resource/listingstatus/Reserved.png", 
"Blocked", "http://firstmallorca.force.com/static/resource/listingstatus/Blocked.png", 
"Rented by FM", "http://firstmallorca.force.com/static/resource/listingstatus/RentedbyFM.png", 
"Rented by competitor", "http://firstmallorca.force.com/static/resource/listingstatus/Rentedbycompetitor.png", 
"Rented privately", "http://firstmallorca.force.com/static/resource/listingstatus/Rentedprivately.png", 
"Sold by FM", "http://firstmallorca.force.com/static/resource/listingstatus/SoldbyFM.png", 
"Sold by competitor", "http://firstmallorca.force.com/static/resource/listingstatus/Soldbycompetitor.png", 
"Sold privately", "http://firstmallorca.force.com/static/resource/listingstatus/Soldprivately.png", 
"Withdrawn/Archived", "http://firstmallorca.force.com/static/resource/listingstatus/Withdrawnarchived.png", 
"/s.png"), 
"status color")
I have this custom button with Javascript that is working perfectly fine: 

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")} 

if ({!pba__Offer__c.pba__SystemIsCancelled__c}) { 
alert("{!$Label.pba__Offer_ErrorAlreadyCancelled}"); 
} else { 

if (confirm("{!$Label.pba__Offer_ConfirmCancellation}")) { 

var updateSobject = new sforce.SObject("pba__Offer__c"); 

try { 

updateSobject.Id = "{!pba__Offer__c.Id}" ; 
updateSobject.pba__SystemIsCancelled__c = true; 

result = sforce.connection.update([updateSobject]); 
if (result[0].getBoolean("success")) { 
location.reload(true); 
} else { 
alert("{!$Label.pba__Generic_ErrorOccured}: " + result[0].errors.message); 


} catch(e) { 
alert("{!$Label.pba__Generic_ErrorOccured}: " + e); 




}


I want to include an additional line to this code, can you please help me on where this new line should go:

if (ISBLANK({!pba__Offer__c.Offer_canceled_comments__c}) { 
alert ("Please specify the reason why the Offer has been canceled!!!!"); 
} else { 
Hi,

We have this problem. We change some setting in the PB Administrator profile as follow:

"13/06/2014 9:40:55 CEST","bp@firstmallorca.com","Changed profile PB Administrator: administrative permission Manage Auth. Providers was changed from disabled to enabled","Manage Users",""
"13/06/2014 9:40:55 CEST","bp@firstmallorca.com","Changed profile PB Administrator: administrative permission Api Only User was changed from disabled to enabled","Manage Users",""
"13/06/2014 9:40:55 CEST","bp@firstmallorca.com","Changed profile PB Administrator: general user permission View Encrypted Data was changed from disabled to enabled","Manage Users",""
"13/06/2014 9:40:55 CEST","bp@firstmallorca.com","Changed profile PB Administrator: administrative permission Edit Read Only Fields was changed from disabled to enabled","Manage Users",""
"13/06/2014 9:40:55 CEST","bp@firstmallorca.com","Changed profile PB Administrator: administrative permission Manage Chatter Messages was changed from disabled to enabled","Manage Users",""

Since we change by mystae this setting when we try to log in the system we receive the insufficient privillege message. We only get this message on the system administrator profiles and since we have all 3 licences as system administrator in this profile none of us are able to log in anymotre. The other licences that we have are working fine but doesnt have the permission to change settings. 

I really nead that soemone can help us with this as we are unnable to work.

Thanks,
Bogdan

Hi everyone 

I would appreciate if anyone can help me with transforming the following trigger in to an apex batch 

trigger ListingRankingManagementTrigger on pba__Listing__c (after insert, after update) {
  
  
    // To avoid exceeding governor limits,
   // use a float to reorder and have an unattended process (batch) pass it to integers again
  
    List<pba__Listing__c> listings = Trigger.new;

    Map<Id, pba__Listing__c> oldListings = null;
    if (!Trigger.isInsert) {
      oldListings = Trigger.oldMap;
    }

    for (pba__Listing__c listing : listings) {

      boolean doMove = true;
      integer addFactor = 0;

     / * If we move the ranking we have to locate the listing that had the new ranking before and - If the new ranking is lower than the old one, add one - If the new ranking is higher than the old one, subtract one
   * /
      
      if (!Trigger.isInsert) {
        pba__Listing__c oldListing = oldListings.get(listing.Id);
        doMove = (oldListing.Ranking__c != listing.Ranking__c );
        if (oldListing.Ranking__c == null || listing.Ranking__c < oldListing.Ranking__c) {
          addFactor = 1;
        } else {
          addFactor = -1;
        }
      } else {    
         // If it is an insert, it is as if the previous ranking was the highest
        addFactor = 1;
      }
      
      if (listing.Ranking__c == null) {
       // If ranking has not been included, we do not move
        doMove = false;
      }
      
      if (doMove) {
        List<pba__Listing__c> prevListings = [Select Id, Ranking__c from pba__Listing__c l where l.Ranking__c =:listing.Ranking__c AND l.id != :listing.id];
        if (prevListings.size()>0) {
          pba__Listing__c prevListing = prevListings.get(0);
         // We have the listing that was previously in our Ranking. We are going to insert it between us and the following ranking
          pba__Listing__c nextListing = null;
          if (addFactor > 0) {
            nextListing = [Select Ranking__c from pba__Listing__c l where l.Ranking__c > :listing.Ranking__c order by Ranking__c ASC LIMIT 1];
          } else {
            nextListing = [Select Ranking__c from pba__Listing__c l where l.Ranking__c < :listing.Ranking__c order by Ranking__c DESC LIMIT 1];
          }
          if (nextListing != null) {
            prevListing.Ranking__c = (prevListing.Ranking__c + nextListing.Ranking__c) / 2;
            update prevListing;
          }
          
        }
          
      }
    }
  

}
I have the following trigger and I would need some help in creating the test class. Any help will be appreciated. 
 
trigger listingLocationUpdate on pba__Listing__c (before insert, before update) {

    //Mantiene actualizado el picklist Location en base al lookup Location
    List<pba__Listing__c> listings = Trigger.new;
    Map<Id, pba__Listing__c> oldListings = null;
    if (!Trigger.isInsert) {
        oldListings = Trigger.oldMap;
    }

    for (pba__Listing__c listing : listings) {

        if (!Trigger.isInsert) {
            pba__Listing__c oldListing = oldListings.get(listing.Id);
            if (oldListing.Location__c == listing.Location__c) {
                continue;
            }
        }
        if (listing.Location__c == null) {
            listing.fm_Location__c = null;
            continue;
        }

        pba__Location__c l = [Select Name from pba__Location__c where Id =:listing.Location__c];
        if (l != null) {
            listing.fm_Location__c = l.Name;
        }

    }
}

 
Hello I would need some help in building a trigger on the Event object. I need to copy the value from a custom field "ClientFeedback__c" to a standard one on the same object: "Description". I am missing this part from the trigger. 
 
trigger showingWorkflowTrigger on Event (after insert, after update) {

        List<Event> events = Trigger.new;
        Map<Id, Event> oldEvents = null;
        if (Trigger.isUpdate) {
            oldEvents = Trigger.oldMap;
        }
        
        
        for (Event event : events) {
            
            RecordType rt = [Select Name FROM RecordType where Id=:event.RecordTypeId];
            
            if (rt.Name == 'Showing' && event.WhoId != null) {


}
                
                if (Trigger.isUpdate) {
                     Event oldEvent = oldEvents.get(event.Id);

 
I have the following trigger on a custom object. Basically it counts the nr of characters from a text filed and display the info in to a numeric filed. The trigger is working as expected when the object is being updated but it fails when you create a new one. 

trigger count_nr_of_characters_on_sales_description_es on pba__Property__c (before insert, before update){ 
for(pba__Property__c a: Trigger.new){ 
System.debug('Number of Characters for Description Field: ' + a.fm_web_Long_description_es__c.length()); 
a.Nr_of_characters_sales_description_es__c = a.fm_web_Long_description_en__c.length(); 

}
Hello 

Since Summer 18 release I have notice that the images are not loading in Salesforce: templates, formulas, etc and I always get this kind of error: 

Refused to load the image '<URL>' because it violates the following Content Security Policy directive: "img-src <URL> *.eu10.content.force.com:* 'self' data:".

This is one of the images that want to display in a template: <apex:image id="theImage" value="{!URLFOR($Resource.SignatureMallorcaOpen, 'Mallorca_open.png')}" width="437" height="215px" alt="Description of image here"/>


If you upload the file as a documenta and use the link it is working. It should work as well with Static Resources. 

Has anyone knoiw how to fix this? 
Hi I have this formula which is working fine. Now I would like to include in the formula this line

IMAGE( IF( pba__SystemHasClosedClosing__c  = True , "http://firstmallorca.force.com/static/resource/listingstatus/Closing.png",""), "")

Can you please help me to onclude this line in to the formula. 

Also this picklist value shoul be condioned only if pba__SystemHasClosedClosing__c  = False

IMAGE( 
CASE( pba__Status__c , 
"In Acquisition", "http://firstmallorca.force.com/static/resource/listingstatus/Inpreparation.png", 
"In Preparation", "http://firstmallorca.force.com/static/resource/listingstatus/Inpreparation.png", 
"Active", "http://firstmallorca.force.com/static/resource/listingstatus/Active.png", 
"Reserved", "http://firstmallorca.force.com/static/resource/listingstatus/Reserved.png", 
"Blocked", "http://firstmallorca.force.com/static/resource/listingstatus/Blocked.png", 
"Rented by FM", "http://firstmallorca.force.com/static/resource/listingstatus/RentedbyFM.png", 
"Rented by competitor", "http://firstmallorca.force.com/static/resource/listingstatus/Rentedbycompetitor.png", 
"Rented privately", "http://firstmallorca.force.com/static/resource/listingstatus/Rentedprivately.png", 
"Sold by FM", "http://firstmallorca.force.com/static/resource/listingstatus/SoldbyFM.png", 
"Sold by competitor", "http://firstmallorca.force.com/static/resource/listingstatus/Soldbycompetitor.png", 
"Sold privately", "http://firstmallorca.force.com/static/resource/listingstatus/Soldprivately.png", 
"Withdrawn/Archived", "http://firstmallorca.force.com/static/resource/listingstatus/Withdrawnarchived.png", 
"/s.png"), 
"status color")
I have this custom button with Javascript that is working perfectly fine: 

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")} 

if ({!pba__Offer__c.pba__SystemIsCancelled__c}) { 
alert("{!$Label.pba__Offer_ErrorAlreadyCancelled}"); 
} else { 

if (confirm("{!$Label.pba__Offer_ConfirmCancellation}")) { 

var updateSobject = new sforce.SObject("pba__Offer__c"); 

try { 

updateSobject.Id = "{!pba__Offer__c.Id}" ; 
updateSobject.pba__SystemIsCancelled__c = true; 

result = sforce.connection.update([updateSobject]); 
if (result[0].getBoolean("success")) { 
location.reload(true); 
} else { 
alert("{!$Label.pba__Generic_ErrorOccured}: " + result[0].errors.message); 


} catch(e) { 
alert("{!$Label.pba__Generic_ErrorOccured}: " + e); 




}


I want to include an additional line to this code, can you please help me on where this new line should go:

if (ISBLANK({!pba__Offer__c.Offer_canceled_comments__c}) { 
alert ("Please specify the reason why the Offer has been canceled!!!!"); 
} else {