Javascript Call Salesforce Method

————– Sample1 ————
Condition: Service Method is Exist

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

{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jquery_js')}

//sforce.connection.sessionId = "{!$Api.Session_ID}";
// Class,Method {ParameName1: Value1, ParamName2: Value2}
var checkRs = sforce.apex.execute("XXXXX_CLass1","XXXX_Method1",{pleadId:leadidVal});

————- GETRECORDIDS ————–

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

var clearnRecords= {!GETRECORDIDS($ObjectType.RoomsStatus__c)};

if (clearnRecords.length < 1) {
     alert(“一件以上選択してください。”);
} else {
     // 選択したデータを取得、未清掃データを削除する
     var checkRs = sforce.apex.execute(‘namespace.RoomStatusManager’, ‘deleteUnCleanRoom’, {ids:clearnRecords});
     if (checkRs != “”) {
           alert(checkRs.length);
     } else {
           location.reload(true);
     }
}

—– class ——

webservice static String deleteUnCleanRoom(String[] idsLst) {

 

————– Sample2 ————
Condition: @RemoteAction (Version > Ver23)

ClassName.ClassMethod(parameVal1,parameVal2,...., showResult, {escape:true});

function showResult(result, event) {
    if (event.type == 'exception') {
        alert(event.message);
    } else {
        // Clear all Event
        $j('#calendar').fullCalendar('removeEvents');
        if (result != null) {

            eventsArray = new Array();
            // 取得する結果を表示する
            for (var i = 0; i < result.length; i++) {
                  .....
            }
         }
      }
}
				entryId,elevatorId,elevatorSingId,handlePlaceId,centerId,recTypeId,operSobjId, showResult, {escape:true});

————– Sample3 ————
Direct Edit Object Value

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

コメントを残す

メールアドレスが公開されることはありません。