• chrinderPWW
  • NEWBIE
  • 0 Points
  • Member since 2013
  • Dir Application Dev
  • Project: WorldWide (Dev Profile @proj)

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 6
    Replies

I can't figure out why in an @RemoteAction method you would want to JSON.serialize the object being returned? I see this in a lot of code and I'm trying to understand the reasoning. I thought @RemoteAction automatically serialized it for you. In fact when doing this it appears you must decode using htmlDecode since it's double encoded, once by Javascript Remoting and again by JSON.serialize method.

I trying to understand from an application design perspective the benefit of doing JSON.serialize and returning a String versus just returning the object/class when using JavaScript Remoteing.

Why do this:

@RemoteAction
public static List<User> searchUsersByName(String searchText) {
    return ChatterUIPeopleService.searchUsersByName(searchText);
}

Versus doing this:

@RemoteAction
public static String searchUsersByName(String searchText) {
    return JSON.serialize(ChatterUIPeopleService.searchUsersByName(searchText));
}
Does anyone have a solution for the following issue?

I've setup Identity Connect 2.1.0 on with MS-SQL as a back end but I'm not able to get the managerID field to populate using the default transformation rule:

ManagerID to Manager
(function () {
  try {

    if (!source || !source.length) {
      return null;
    }

    var
      orgId = "00DA0000000gukE", 
      link, 
      qry = openidm.query("system/AD/account", { 
          "query": { 
            "Equals": { 
              "field": "distinguishedName", 
              "values": [ source ] 
            } 
          }
        });

    if (!qry.result || qry.result.length !== 1) {
      return null;  
    }

    link = openidm.query("repo/link", { 
      "_queryId": "links-for-firstId",
      "linkType": "ADUsers_SalesForceUsers_" + orgId,
      "firstId": encodeURIComponent(qry.result[0].objectGUID)
    });

    if (!link.result || link.result.length !== 1) {
      return null;
    } else {
      return link.result[0].secondId;
    }

  } catch ( e ) {
    return null;
  }

}());


This rule works fine if I use OrientDB as the back end, but doesn't work when I use MS-SQL as the back end. Perhaps an issue with OpenIDM?
I need to send a URL string with certain Opportunity fields in it when an custom check box on the opportinity is checked.  Would I need a trigger and an API call to do this, or is there an easier way?
Hi, how can i default a dependent picklist value if there is only one value?

for example, i have controling picklist value of A,B,C and dependent picklist value of 1,2,3,6,7,8

A - 1,2,3
B - 6
C - 7,8

so when i select B my dependent picklist will automatically show 6 instead of None and need to choose again since there is only onle value there.

Hi guys! I am a new developer, and I have trouble writig test class for the following batch class. Any kind of help is greatly appreciated. Thanks in advance. 

global class batchAccountsImport implements 
             Database.Batchable<SObject>,Database.AllowsCallouts {
  
  global Database.queryLocator 
                    start(Database.BatchableContext ctx){
        return Database.getQueryLocator([select id,safariUserId__c, isActive from User where isactive = true]);
    }
    global void execute(Database.BatchableContext ctx, List<Sobject> scope){
       String url = 'http://75.24.90.133:8080/restdemo/services/webservices';
       
       List<User> sfuser = (List<User>)scope; 
       List<Account> finalAccts = new List<Account>();
       system.debug('################################################################'+sfuser.size());
       
       for(integer i=0; i<sfuser.size(); i++)
       {
          Http http1 = new Http();
          System.debug('callout 1');
          HttpRequest req1 = new HttpRequest();
          //req1.setTimeout(120000); // timeout in milliseconds
          req1.setEndpoint(url+'/customers/'+sfuser[i].safariUserId__c);
          System.debug('################'+sfuser[i].safariUserId__c );
          req1.setMethod('GET');
          HttpResponse res1 = http1.send(req1);
          String xmlContent1= res1.getbody();
          Id userid = sfuser[i].id;
          List<Account> allAccts = xmlParser(xmlContent1,userid);
          for(integer j=0; j<allAccts.size();j++)
          {
             finalAccts.add(allAccts[j]);
          }
       }
       insert finalAccts;
    }
    
          
          public List<Account> xmlParser(String strXml1,Id currentUserid)
          {
          //Log the XML content
          System.debug('########Inside XMLParser Method########');
          Dom.Document doc1 = new Dom.Document();
          doc1.load(strXml1);
               
          List<Account> NewAccts = new List<Account> ();
        
          dom.XmlNode xroot1 = doc1.getrootelement();
          dom.XmlNode [] xrec1 = xroot1.getchildelements(); //Get all Record Elements
        
          for(Dom.XMLNode child1 : xrec1) //Loop Through Records
          {
             Account acct = new Account();
 
             for (dom.XmlNode awr1 : child1.getchildren() ) {
                    
                if (awr1.getname() == 'customerName') {
                   system.debug('#####################' + awr1.gettext());
                   acct.Name = awr1.gettext();
                }

                if (awr1.getname() == 'customerAccountType') {
                   system.debug('#####################' + awr1.gettext());
                   acct.Type = awr1.gettext();
                }  
      
                if (awr1.getname() == 'customerAddress') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingStreet = awr1.gettext();
                }
                
                if (awr1.getname() == 'customerCity') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingCity =awr1.gettext();
                }
                    
                if (awr1.getname() == 'customerZip') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingPostalCode = awr1.gettext();
                } 
      
                if (awr1.getname() == 'customerState') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingState = awr1.gettext();
                }
                
                if (awr1.getname() == 'customerCountry') {
                   system.debug('#####################' + awr1.gettext());
                   acct.BillingCountry = awr1.gettext();
                }
                
                if (awr1.getname() == 'customerId') {
                   system.debug('#####################' + awr1.gettext());
                   acct.safariAccId__c = awr1.gettext();
                }
                  
                if (awr1.getname() == 'userid') {
                   system.debug('#####################' + awr1.gettext());
                   acct.ownerId = currentUserid;
                }  
                
             }
             NewAccts.add(acct);
        
          }
          //insert NewAccts;
          return NewAccts;
      }
      global void finish(Database.BatchableContext ctx){
      
         //Send an email to the User after your batch completes  
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
         String[] toAddresses = new String[] {'samhita.ps@gmail.com'};  
         mail.setToAddresses(toAddresses);  
         mail.setSubject('Apex Batch Job is done');  
         mail.setPlainTextBody('The batch Apex job processed ');  
         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
      }

 }

Does anyone have a solution for the following issue?

I've setup Identity Connect 2.1.0 on with MS-SQL as a back end but I'm not able to get the managerID field to populate using the default transformation rule:

ManagerID to Manager
(function () {
  try {

    if (!source || !source.length) {
      return null;
    }

    var
      orgId = "00DA0000000gukE", 
      link, 
      qry = openidm.query("system/AD/account", { 
          "query": { 
            "Equals": { 
              "field": "distinguishedName", 
              "values": [ source ] 
            } 
          }
        });

    if (!qry.result || qry.result.length !== 1) {
      return null;  
    }

    link = openidm.query("repo/link", { 
      "_queryId": "links-for-firstId",
      "linkType": "ADUsers_SalesForceUsers_" + orgId,
      "firstId": encodeURIComponent(qry.result[0].objectGUID)
    });

    if (!link.result || link.result.length !== 1) {
      return null;
    } else {
      return link.result[0].secondId;
    }

  } catch ( e ) {
    return null;
  }

}());


This rule works fine if I use OrientDB as the back end, but doesn't work when I use MS-SQL as the back end. Perhaps an issue with OpenIDM?