Unable to modify Status Code of appointment - dynamics-crm-2011

In order to meet a client requirment, I need to modify the status and status reason fields of the entity appointment in CRM 2011.
Is there a way to achieve this ?

You cannot add more status values to appointment.
From the UI, you can add only add or edit status reasons for the open status.
If you want to add status reasons for other statuses, you can use an InsertStatusValueRequest.
var insertStatusValueRequest =
new InsertStatusValueRequest
{
AttributeLogicalName = "statuscode",
EntityLogicalName = Appointment.EntityLogicalName,
Label = new Label("Not-Done", _languageCode),
StateCode = 1
};
_serviceProxy.Execute(insertStatusValueRequest);

Related

How to Create a Purchase Receipt with Document Details via code

The Goal is creating a Purchase Order and then its corresponding Purchase Order receipt via code with 2 separate actions/buttons.
The PO (Type Normal) is created without any issues. And is then Approved via code making it visible in the "Add Purchase Order" smartpanel from the Purchase Receipt page.
The UI workflow would be the selection of the PO order and then pressing on "ADD PO".
I'm looking to replicate that via code.
Looking at the page's ASPX definition I can see that the smartpanel button is associated to action AddPOOrder2
I'm creating the Purchase receipt like this:
if (orderRecord.Approved == true)
{
poReceiptEntryGraph = PXGraph.CreateInstance<POReceiptEntry>();
receiptRow = new POReceipt();
//Summary
receiptRow.ReceiptType = "RT";
receiptRow = poReceiptEntryGraph.Document.Insert(receiptRow);
receiptRow.Hold = false;
receiptRow.ReceiptDate = DateTime.Now;
receiptRow.VendorID = orderRecord.VendorID;
receiptRow.InvoiceNbr = "123";
poReceiptEntryGraph.Document.Update(receiptRow);
poReceiptEntryGraph.Actions.PressSave();
Then I create a PXView:
int startActualRow = PXView.StartRow;
int totalActualRows = 1;
List<Object> createdView = new PXView(poReceiptEntryGraph, false, PXSelect<POOrder, Where<POOrder.orderNbr, Equal<Required<POOrder.orderNbr>>>>
.GetCommand()).Select(PXView.Currents, /*Filter value from the BQL Required*/ new object[] { "PO000683"/*orderRecord.OrderNbr*/ },
PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
ref startActualRow, PXView.MaximumRows, ref totalActualRows);
PXView dummyActualView = new DummyView(poReceiptEntryGraph, poReceiptEntryGraph.Document.View.BqlSelect, createdView);
Finally, the PXView is used to press on the AddPOOrder2 action:
poReceiptEntryGraph.addPOOrder2.Press(new PXAdapter(dummyActualView));
poReceiptEntryGraph.Actions.PressSave();
No error messages are received and the summary section of the Receipt gets created correctly but without any content in the grid.
I also attempted to use addPOOrder which is another Acumatica action that executes addPOOrder2 but the result was the same.
Any ideas if I'm missing something?
Thanks.
I found the solution for this.
Acumatica's AddPOOrder2 action iterates over the selected records and invokes method AddPurchaseOrder
Invoking the method directly in my action worked correctly:
if (orderRecord.Approved == true)
{
poReceiptEntryGraph = PXGraph.CreateInstance<POReceiptEntry>();
receiptRow = new POReceipt();
receiptRow.ReceiptType = "RT";
receiptRow = poReceiptEntryGraph.Document.Insert(receiptRow);
receiptRow.Hold = false;
receiptRow.ReceiptDate = DateTime.Now;
receiptRow.VendorID = orderRecord.VendorID;
poReceiptEntryGraph.Document.Update(receiptRow);
poReceiptEntryGraph.Actions.PressSave();
poReceiptEntryGraph.AddPurchaseOrder(orderRecord);
poReceiptEntryGraph.Actions.PressSave();
}
However, I wonder, had the method not existed, was I in the correct path with the use of the PXView and the PXAdapter? Is it possible to execute other similar actions that may not have a method?

NetSuite: How do I populate a custom transaction field with the ship-to custom address field

In NetSuite, how do I populate a custom transaction field
(custbody_site_no_shipto)
on a transaction (for example, a Sales Order) with a custom address field
(custrecord_site_no)
for the Ship-To Address selected (under the Shipping tab)?
Custom transaction field: custbody_site_no_shipto
(Menu: Customization > Lists, Records, & Fields > Transaction Body Fields – Display Type is Inline Text).
Custom address field: custrecord_site_no
(Menu: Customization > Lists, Records, & Fields > Other Custom Fields – Checked Apply To All Custom Address Forms).
Usually, you would configure the sourcing of the custom field on the 'Sourcing and Filtering'.
However, shipping address is not included the 'Source List'.
So to cater that requirements, you might only do automation/customization either by SuiteFlow or SuiteScript (Client Side or User Event script).
And looking to your requirements, it seems you can only do this using after submit user event script. It is because the "Address" you wanted to access is a subrecord and not all APIs for it can be used on client side script. I have example below:
var recSO = nlapiLoadRecord('salesorder', 34826,
{
recordmode : 'dynamic'
});//34826 is the internal id of SO
var recSubAddress = recSO.viewSubrecord('shippingaddress');//Ship To field id
var stSiteN0 = recSubAddress.getFieldValue('custrecord_site_no');
recSO.setFieldValue('custbody_site_no_shipto', stSiteN0);
var stRecId = nlapiSubmitRecord(recSO);
The script below works and was implemented as a User Event Script.
function userEventBeforeSubmit(type) {
var shipadd = nlapiGetFieldValue('shipaddresslist');
var customer = nlapiGetFieldValue('entity');
var record = nlapiLoadRecord('customer', customer,{recordmode: 'dynamic'});
var linenum = record.findLineItemValue('addressbook', 'internalid', shipadd);
record.selectLineItem('addressbook', linenum);
var subrecord = record.viewCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
var customfield1 = subrecord.getFieldValue('custrecord_site_no');
nlapiSetFieldValue('custbody_site_no_shipto', customfield1);
}

How to mark a SalesOrder Picked then Packed using NetSuite SuiteTalk WebServices

My objective is to respond to a picked event in an external system and mark the SalesOrder "Picked" in NetSuite and later respond to a pack event in an external system and mark the SalesOrder "Packed" in NetSuite.
I am using the code from the SuiteTalk sample application. I first get a copy of the existing ItemFulfillment record and then populate a new ItemFulfillment record.
The code works great when I respond to the pick event. Unfortunately, when I respond to the pack event, when I try to get a copy of the existing ItemFulfillment Record for the SalesOrder I get this error.
"You must have at least one valid line item for this transaction."
I assumed that NetSuite is complaining that there are no more line items to fulfill, so I tried not adding any ItemFulfillmentItem(s) when I set the status to picked, but NetSuite didn't like that either.
The only documentation that I could find referenced a task Id, /app/accounting/transactions/itemshipmanager.nl?type=pack. This approach seemed credible because when I brought up Fiddler, this is the call that it made when I click the "Mark Packed" button in the UI. However, I would prefer not to introduce a different paradigm for talking to the NetSuite server.
I have found that NetSuite will let me go straight to the Pack state if I set shipStatus and shipStatusSpecified in the ItemFulfillment.
Can I move a SalesOrder through both the picked and packed states using only NetSuite SuiteTalk?
I was going about the problem incorrectly. Instead of adding items to a new packed item fulfillment, the correct approach is to find the existing ItemFulfillment and change its status to packed.
This is the search that finds an existing ItemFulfillment for a SalesOrder:
TransactionSearch xactionSearch = new TransactionSearch
{
basic = new TransactionSearchBasic
{
type = new SearchEnumMultiSelectField
{
#operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new System.String[]
{
"_itemFulfillment"
}
},
createdFrom = new SearchMultiSelectField
{
#operator = SearchMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new RecordRef[1]
{
new RecordRef
{
internalId = salesOrderInternalId,
type = RecordType.salesOrder,
typeSpecified = true
}
}
}
}
};
This is the code that updates the ItemFulfillment:
ItemFulfillment update = new ItemFulfillment { internalId = existing.internalId, shipStatus = status, shipStatusSpecified = true };
WriteResponse res = _service.update(update);

Create A Record as Closed with C#

Can a record be created as closed?
If I create the records and then change the state, that could work, but is it possible to do it in a single step?
I am using ExecuteMultipleRequest to create Cases.
No, You have to make two request to create and resolve the case. See the examples below:
// Create an incident.
var incident = new Incident
{
CustomerId = new EntityReference(Account.EntityLogicalName, _accountId),
Title = "Sample Incident"
};
_incidentId = _serviceProxy.Create(incident);
// Create the incident's resolution.
var incidentResolution = new IncidentResolution
{
Subject = "Resolved Sample Incident",
IncidentId = new EntityReference(Incident.EntityLogicalName, _incidentId)
};
// Close the incident with the resolution.
var closeIncidentRequest = new CloseIncidentRequest
{
IncidentResolution = incidentResolution,
Status = new OptionSetValue((int)incident_statuscode.ProblemSolved)
};
_serviceProxy.Execute(closeIncidentRequest);
Ref: sdk\SampleCode\CS\BusinessDataModel\Service\CloseAnIncident.cs
You will always need two request, one to create the record and one to change the state.
You could have a plugin close the record on the create, so that way it happens in the same database transaction, but I'm guessing that it wouldn't be worth the over head.

Appointment Send and Send Update

How can I know if for any appointment "Send" was clicked or " Send Update" or "Send Cancellation" was clicked.I have Application_ItemSend event which fires for both Send,Send Update and Send Cancellation. One way would be add a custom property and set some value when the appointment is initially created. But I don't seem to find a way to differentiate the button click. Is adding custom property the only way or is there any built in property which I can use. Appointment item I am assigning as below.
var appointment = Globals.MedearcOutlook2010AddIn.Application.ActiveInspector().CurrentItem as Outlook.AppointmentItem;
Thanks
You can check the MAPI property PR_MESSAGE_DELIVERY_TIME to see whether the appointment has been sent yet (isUpdate=false) or it is an update to an existing appointment (isUpdate=true). I didn't see a native property member for doing this.
string PR_MESSAGE_DELIVERY_TIME = "http://schemas.microsoft.com/mapi/proptag/0x0E060040";
bool isUpdate = false;
try
{
DateTime message_delivery = appointment.PropertyAccessor.GetProperty(PR_MESSAGE_DELIVERY_TIME);
isUpdate = true; // if it makes it here then the message has been delivered
}
catch { }

Resources