Passing Form Fields through REST API

Completed

Comments

3 comments

  • Avatar
    Loren Bratzler

    Have you tried using the variable names with dollar sign and brackets like this:

    {Name = "${/pd:AP/pd:formFields/pd:Sponsor}", Value = model.SponsorName}
    0
    Comment actions Permalink
  • Avatar
    Olugbenro Selere

    Hi Loren,

    The previous approach worked. I was passing the wrong value to the WorkObjectId field in the JSON object. 

    I did try passing a list of data to a subform using the API, and saw that only one of the items in the list showed up in the formFields subform property.

    Is there a way to pass the data as a string and split them back on the agilepoint process?

    foreach (var timeline in model.ContractParts)
    {
    timelines.Add(new Attributes { Name = $"/pd:AP/pd:formFields/pd:TimelineSubform_SubForm/pd:TimelineSubform/pd:{nameof(timeline.PartName)}Subform", Value = timeline.PartName });
    timelines.Add(new Attributes { Name = $"/pd:AP/pd:formFields/pd:TimelineSubform_SubForm/pd:TimelineSubform/pd:{nameof(timeline.FirstSiteInitiateDate)}Subform", Value = timeline.FirstSiteInitiateDate?.ToShortDateString() });
    timelines.Add(new Attributes { Name = $"/pd:AP/pd:formFields/pd:TimelineSubform_SubForm/pd:TimelineSubform/pd:{nameof(timeline.FirstSubjectFirstVisit)}Subform", Value = timeline.FirstSubjectFirstVisit?.ToShortDateString() });
    timelines.Add(new Attributes { Name = $"/pd:AP/pd:formFields/pd:TimelineSubform_SubForm/pd:TimelineSubform/pd:{nameof(timeline.LastSubjectLastVisit)}Subform", Value = timeline.LastSubjectLastVisit?.ToShortDateString()});
    }

    agilePoint.Attributes = new List<Attributes>
    {
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ContractSponsor", Value = model.SponsorName},
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ContractProtocol", Value = $"{model.ProtocolID}" },
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ActiveContractID", Value = $"{model.Id}"},
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ProposalDate", Value = $"{DateTime.Now.ToShortDateString()}"},
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ProtocolVersion", Value = $"{model.ContractVersion}"},
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ProtocolPhase", Value = $"{model.Phase}"},
    new Attributes {Name = "/pd:AP/pd:formFields/pd:ExtraPercentage", Value = $"{model.ExtraSupplyPercentage}"},
    };

    agilePoint.Attributes.AddRange(timelines);
    2
    Comment actions Permalink
  • Avatar
    Aravind Rajanna

    Hello,

    We have a sample code snippet in the given documentation link. Please refer the below link.

    https://documentation.agilepoint.com/8011/developer/websvcsmethodCreateProcInst.html

    https://documentation.agilepoint.com/8011/developer/restmethodCreateProcInst.html

    Hope this helps

    Regards,

    Aravind Rajanna

    0
    Comment actions Permalink

Please sign in to leave a comment.