Passing Form Fields through REST API
CompletedHello,
I have an app that starts with a form, and passes the values from the form to a Microsoft Word Activity to create a SharePoint document.
I'm using a C# Web Client to initiate the REST API call to my AgilePoint Server but when I pass the formField values, they are not passed on the corresponding form.
This is the structure of my request for the formFilelds:
agilePoint.Attributes = new List<Attributes>
{
new Attributes {Name = "/pd:AP/pd:formFields/pd:Sponsor", Value = model.SponsorName},
new Attributes {Name = "/pd:AP/pd:formFields/pd:Protocol", Value = $"{model.ProtocolID}" },
new Attributes {Name = "/pd:AP/pd:formFields/pd:ContractID", Value = $"{model.Id}"}
};
Is there something I'm not doing right?
-
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); -
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
Please sign in to leave a comment.
Comments
3 comments