2014-12-22 1 views
0

내 목표는 여러 리소스와 관련된 서비스 약속 레코드를 만드는 것입니다.CRM 2013에서 javascript로 OData 끝점을 사용하여 서비스 약속 엔티티에 여러 리소스 연결

이 목적을 위해 나는 this MSDN example을 따라갔습니다.

하나의 특정 서비스 약속에 대해 여러 리소스를 연결하려고하면 문제가 발생합니다. CRM 서버는 마지막 하나 (1 레코드) 만 저장합니다. 다음은 내 코드를 보여줍니다.

//attendees =[... array of resource ids] 
var serviceAppointment = { 
     ScheduledStart: new Date("12/22/2014 4:53 PM"), 
     ScheduledEnd: new Date("12/22/2014 5:53 PM"), 
     Subject: "test service", 
     ServiceId: 
     { 
      //// hardcoded id for simplicity 
      Id: "6f795012-ca55-e411-aa38-00155d0a0948", 
      LogicalName: "service" 
     } 
    }; 
    SDK.JQuery.createRecord(serviceAppointment,"ServiceAppointment" 
    ,function(sa){ 
     for(var i=0;i<attendees.length;i++) 
     { 
      var activityParty = { 
       PartyId: 
       { 
        Id: attendees[i], 
        LogicalName: "systemuser", 
       }, 
       ActivityId: 
       { 
        Id: sa.ActivityId, 
        LogicalName: "serviceappointment", 
       }, 
       ParticipationTypeMask: 
       { 
        //See http://msdn.microsoft.com/en-us/library/gg328549.aspx 
        //10 is for resource 
        Value: 10 
       } 
      }; 
      SDK.JQuery.createRecord(activityParty,"ActivityParty", function(ap){debugger;},errorHandler); 
     } 
    } 
    ,errorHandler); 

코드를 디버깅하는 한 예외없이 예외없이 코드가 올바르게 실행됩니다. 내 코드 어딘가에 구성 플래그가없는 것 같아 CRM은 일대일 방식이 아닌 일대일 방식을 고려하고 있습니다. 실마리가 있습니까?

답변

0

서비스 약속 레코드에 상대방 배열을 끝에 하나씩 삽입하는 대신 처음에 전달하여이 문제를 해결할 수 있습니다. 다음은 작동하는 코드입니다.

var parties =[]; 
    for(var i=0;i< e.event.attendees.length;i++) 
    {   
     var activityParty = { 
      PartyId: 
      { 
       Id: e.event.attendees[i], 
       LogicalName: "systemuser", 
      }, 
      ParticipationTypeMask: 
      { 
       //See http://msdn.microsoft.com/en-us/library/gg328549.aspx 
       //10 is for resource 
       Value: 10 
      } 
     } 
     parties.push(activityParty); 
    } 
    var serviceAppointment = { 
     ScheduledStart: e.event.start, 
     ScheduledEnd: e.event.end, 
     Subject: e.event.title, 
     ServiceId: 
     { 
      Id: "6f795012-ca55-e411-aa38-00155d0a0948", 
      LogicalName: "service" 
     }, 
     serviceappointment_activity_parties: parties, 
    }; 


    SDK.JQuery.createRecord(serviceAppointment,"ServiceAppointment" 
    ,function(sa){ 
     debugger; 
     e.event.ActivityId = serviceAppointmentActivityId = sa.ActivityId; 
    } 
    ,errorHandler); 
    } 

희망이있는 사람을 도와주세요.