Netsuite search salesorder by customfield - c#

Have a salesorder opject and I want to search by using a tranid field.
how can I do that?
I know how to search by using internalid or extrenalid, but no clue about tranid

Here is an example of how to do this in C#.
SearchResult result = service.search(new TransactionSearch()
{
basic = new TransactionSearchBasic()
{
type = new SearchEnumMultiSelectField() {
#operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new string[] { "_salesOrder" }
},
tranId = new SearchStringField()
{
#operator = SearchStringFieldOperator.#is,
operatorSpecified = true,
searchValue = "SO364886"
}
}
}
);
if(result.status.isSuccess && result.totalRecords == 1)
{
SalesOrder salesOrder = (SalesOrder)result.recordList[0];
System.Console.WriteLine("Internal ID = " + salesOrder.internalId);
} else
{
System.Console.WriteLine("Couldn't find sales order!");
}

Related

Get duplicate Realtime Database Firebase results in Xamarin

I'm trying to build realtime chat through Realtime Database Firebase and Xamarin. However there is a problem like this, hope someone can help:
protected async void LoadChat()
{
string userid = "123456789";
var getroom = (await fc.Child("RecordsChat").OnceAsync<GetRoomChats>()).Select(x =>
new GetRoomChats
{
RoomID = x.Key
}).ToList();
List<GetRoomChats> listroomuser = new List<GetRoomChats>();
foreach (var room in getroom)
{
string str = null;
string[] strArr = null;
string roomget = room.RoomID;
str = roomget + "_";
char[] splitchar = { '_' };
strArr = str.Split(splitchar);
var getroomuser = strArr.Distinct().ToList();
foreach (var item in getroomuser)
{
if (item == userid)
{
var roomgetuser = new GetRoomChats()
{
RoomID = roomget
};
listroomuser.Add(roomgetuser);
}
}
}
if (listroomuser.Count() > 0)
{
var FirebaseClient = fc
.Child("RecordsChat")
.AsObservable<GetRoomChats>()
.Subscribe(async(dbevent) =>
{
//IteamGetRoomChats.Clear();
foreach (var room in listroomuser)
{
if (dbevent.Key == room.RoomID)
{
var lst = (await fc.Child("RecordsChat").Child(dbevent.Key).OrderByKey().LimitToLast(1).OnceAsync<MyDatabaseRecord>()).Select(x =>
new MyDatabaseRecord
{
NameUser = x.Object.NameUser,
Content = x.Object.Content,
RoomID = x.Object.RoomID,
DayCreate = x.Object.DayCreate,
AvatarUser = x.Object.AvatarUser,
sender_uid = x.Object.sender_uid,
receiver_uid = x.Object.receiver_uid,
receiver_read = x.Object.receiver_read
});
bool unread = false;
foreach (var i in lst)
{
if(i.sender_uid == userid)
{
i.Content = "You: " + i.Content;
var customerList = await apiServiceUserinfo.GetCustomersInfo(i.receiver_uid);
string nameget = customerList.NameStore;
string avatarget = customerList.AvatarStore;
i.NameUser = nameget;
i.AvatarUser = avatarget;
if (i.sender_read == true)
{
unread = false;
}
}
else
{
if (i.receiver_read == false)
{
i.BackgroundUser = "#f5f4f4";
unread = true;
}
}
var last = new GetRoomChats()
{
NameLast = i.NameUser,
ContentLast = i.Content,
RoomID = i.RoomID,
DayCreateLast = i.DayCreate,
AvatarLast = i.AvatarUser,
BackgroundUnread = i.BackgroundUser,
DotUnread = unread
};
IteamGetRoomChats.Add(last);
}
}
}
});
}
BindingContext = this;
}
In my example above, it actually gets the data. I try to check in the loop, to get the last content of the message. However, the displayed results are duplicated
Looking forward to everyone's help. Thank you!

How do i validate and give list of options after first wrong attempt in FormFlow Bot Framework

I am trying to build a bot using bot framework where i want to take string from user for a department name using FormFlow and if user enters wrong department name, I want to validate and give back a list of choices to choose from
DepartmentName string:
[Prompt("What is your department name? {||}")]
public string DepartmentName { get; set; }
Deaprtment name field is as following:
.Field(nameof(DepartmentName),
validate: async (state, response) =>
{
var value = (string)response;
var result = new ValidateResult() { IsValid = false, Feedback = "Department name is not valid"};
if (Enum.GetNames(typeof(Department)).Any(x => x.ToLower() == value))
{
result.IsValid = true;
result.Feedback = null;
result.Value = value;
}
return result;
})
Department enum is as following:
public enum Department
{
hr = 1,
sales,
marketing,
development,
qm
}
How can i prompt user with list of departments in enum if first attempt goes wrong? Thnaks
1) you can just add the options to the end of the Feedback:
.Field(nameof(DepartmentName),
validate: (state, response) =>
{
var value = (string)response;
string[] departments = Enum.GetNames(typeof(Department)).ToArray();
var feedback = $"Department name is not valid. Options:\n\n {String.Join("\n\n", departments)}";
var result = new ValidateResult() { IsValid = false,
Feedback = feedback };
if (departments.Any(x => x.ToLower() == value))
{
result.IsValid = true;
result.Feedback = null;
result.Value = value;
}
return Task.FromResult<ValidateResult>(result);
});
2) you can use the Choice class (normally for disambiguation):
.Field(nameof(DepartmentName),
validate: (state, response) =>
{
var value = (string)response;
string[] departments = Enum.GetNames(typeof(Department)).ToArray();
IEnumerable<Choice> choices = departments.Select(d => new Choice()
{
Description = new DescribeAttribute(d, null, null, null, null),
Terms = new TermsAttribute() { Alternatives = new[] { d } },
Value = d
}).ToArray();
var result = new ValidateResult()
{
IsValid = false,
Choices = choices,
Feedback = "Department name is not valid."
};
if (departments.Any(x => x.ToLower() == value))
{
result.IsValid = true;
result.Feedback = null;
result.Value = value;
}
return Task.FromResult<ValidateResult>(result);
});

Dropdown list bind using jquery

I would like this type of binding in dropdownbox
-Any Bachelor's Degree-
BCA
BCOM
-Any Master's Degree-
MCA
MBA
-Any Degree-
PGCDA
You can achieve using below, This is just example you cam change as your requirement
function OnSuccess(data) {
$('#ddlAccessLevelGroup').empty();
var d = data;
var dropdown = $('#ddlAccessLevelGroup');
var GroupCode = "";
var optGroup;
for (var i = 0; i < d.length; i++) {
if (d[i].GroupCode.toString() != GroupCode) {
optGroup = $("<optgroup style='background-color:#94c0d2' />");
optGroup.attr('label', d[i].GroupCode.toString());
}
GroupCode = d[i].GroupCode.toString();
optGroup.append(
$('<option></option>').val(d[i].AccessLvlId.toString()).html(d[i].AccessLvlName.toString())
);
dropdown.append(optGroup);
}
}
C# Code
public IQueryable<AccessLevel> TestGetAccessLevelData()
{
IQueryable<AccessLevel> AccessLevelGrp = null;
IQueryable<AccessLevel> AccessLevel = from a in unitOfWork.ACCESS_LEVEL_RXRepository.Get()
select new AccessLevel
{
AccessLvlId = a.ACCESS_LVL_ID_RX,
AccessLvlName = a.ACCESS_LVL_NAME,
GroupCode = "Group A"
};
IQueryable<AccessLevel> AccessLevel1 = from a in unitOfWork.ACCESS_LEVEL_RXRepository.Get()
select new AccessLevel
{
AccessLvlId = a.ACCESS_LVL_ID_RX,
AccessLvlName = a.ACCESS_LVL_NAME,
GroupCode = "Group B"
};
var result = AccessLevel.Union(AccessLevel1);
return result.OrderBy(c=> c.GroupCode);
}

Writing to incidents in C#

I am using CRM 4 and the SDK to grab cases like so:
public List<Case> GetCases()
{
List<Case> cases = new List<Case>();
#region Retrieve Resolved Cases
try
{
InitSession();
RetrieveMultipleRequest req = new RetrieveMultipleRequest();
req.ReturnDynamicEntities = true;
//QueryExpression says what entity to retrieve from, what columns we want back and what criteria we use for selection
QueryExpression qe = new QueryExpression();
qe.EntityName = EntityName.incident.ToString();
List<string> attributes = new string[] {
"incidentid","title" ,"description", "ticketnumber", "statuscode",
"kez_allocatedhours",
"customerid",
"casetypecode"
}.ToList();
//columns to retireve
ColumnSet AvailabilityColumnSet = new ColumnSet();
AvailabilityColumnSet.Attributes = attributes.ToArray();
qe.ColumnSet = AvailabilityColumnSet;
//filter
FilterExpression fe = new FilterExpression();
fe.FilterOperator = LogicalOperator.And;
//condtion for filter
ConditionExpression isResolved = new ConditionExpression();
isResolved.AttributeName = "statuscode";
isResolved.Operator = ConditionOperator.NotEqual;
isResolved.Values = new string[] { "5" };
fe.Conditions = new ConditionExpression[] { isResolved }; //Add the conditions to the filter
qe.Criteria = fe; //Tell the query what our filters are
req.Query = qe; //Tell the request the query we want to use
//retrieve entities
RetrieveMultipleResponse resp = svc.Execute(req) as RetrieveMultipleResponse;
if (resp != null)
{
BusinessEntity[] rawResults = resp.BusinessEntityCollection.BusinessEntities;
List<DynamicEntity> castedResults = rawResults.Select(r => r as DynamicEntity).ToList();
foreach (DynamicEntity result in castedResults)
{
string id = GetProperty(result, "incidentid");
string title = GetProperty(result, "title");
string description = GetProperty(result, "description");
string ticket = GetProperty(result, "ticketnumber");
string customer = GetProperty(result, "customerid");
int statuscode = -1;
string statusname = "";
double estHours = 0.0;
string casetype = "";
int casetypecode = -1;
Property prop = result.Properties.Where(p => p.Name == "statuscode").FirstOrDefault();
if (prop != null)
{
StatusProperty status = prop as StatusProperty;
if (status != null)
{
statuscode = status.Value.Value;
statusname = status.Value.name;
}
}
prop = result.Properties.Where(p => p.Name == "kez_allocatedhours").FirstOrDefault();
if (prop != null)
{
CrmFloatProperty fl = prop as CrmFloatProperty;
if (fl != null)
{
estHours = fl.Value.Value;
}
}
prop = result.Properties.Where(p => p.Name == "casetypecode").FirstOrDefault();
if (prop != null)
{
PicklistProperty fl = prop as PicklistProperty;
if (fl != null)
{
casetype = fl.Value.name;
casetypecode = fl.Value.Value;
}
}
Case c = new Case();
c.ID = id;
c.Title = title;
c.Description = description;
c.StatusCode = statuscode;
c.StatusName = statusname;
c.TicketNumber = ticket;
c.CustomerName = customer;
c.EstimatedHours = estHours;
c.Type = casetype;
c.TypeCode = casetypecode;
bool allowedThroughStat = true;
bool allowedThroughType = true;
var userStatuses = SettingsManager.Get("CRMUserStatusReasons").Split(';').ToList().Where(p => p.Length > 0).ToList();
var userTypes = SettingsManager.Get("CRMUserCaseTypes").Split(';').ToList().Where(p => p.Length > 0).ToList();
if(userStatuses.Count > 0 && !userStatuses.Contains(c.StatusCode.ToString()))
{
allowedThroughStat = false;
}
if (userTypes.Count > 0 && !userTypes.Contains(c.TypeCode.ToString()))
{
allowedThroughType = false;
}
if(allowedThroughStat && allowedThroughType)
cases.Add(c);
}
}
}// end try
catch (Exception)
{
return null;
// The variable 'e' can access the exception's information.
// return "Error Message: " + e.Message.ToString() + " | Stack Trace: " + e.StackTrace.ToString();
}
return cases;
#endregion
}
However, now I need to be able to change the status and title of a case from C# given its incidentid.
Ive looked at the SDK docs and cannot find an example of this.
Anyone work with this before?
Thanks
Simply put, above is code to read an incident. Could I get an example of writing an incident field, Just one. Ex: How could I change the title of an incident.
You can call the Update method on the CrmService. Here is the SDK article.
Case c = new Case();
c.ID = id;
c.Title = title;
svc.Update(c);
To change the state of an entity you use the setstaterequest. If you want to do it to a dynamic entity there's a description in this blog

Find the items matching any condition from the generic list

I have collection of patient in a lists named lst_Patient.
And this is method where i get the info from user:
public Patient[] GetPatientsBySearchParams(DataPair[] dataPair)
{
//return the array patients that match any of the criteria
//Right Now I ma doing this didn't get any success :
List<Patient> P = new List<Patient>();
P = lst_Patient.FindAll(p => { p.FirstName = dataPair[0].OutputValue.ToString();
p.LastName = dataPair[1].OutputValue.ToString();
return true;
return P.ToArray();
}
On a button click i take the info entered in the textbox by the user:
private DataPair[] dpair;
private void Button_Click(object sender, RoutedEventArgs e)
{
InvalidSearch.Visibility = Visibility.Collapsed;
SearchResults.Visibility = Visibility.Visible;
dpair = new DataPair[]{
new DataPair { Name = "FirstName", OutputValue = fst_Name.Text },
new DataPair { Name = "LastName", OutputValue = lst_Name.Text },
new DataPair { Name = "DateOfBirth", OutputValue = dob.Text },
new DataPair { Name = "SSN", OutputValue = ssn.Text },
new DataPair { Name = "PracticeNumber", OutputValue = pract_nbr.Text },
new DataPair { Name = "ReferenceNumber", OutputValue = ref_nbr.Text },
new DataPair { Name = "PlaceOfService", OutputValue = pos.Text },
new DataPair { Name = "DateOfService", OutputValue = dos.Text},
new DataPair { Name = "RenderingProvider", OutputValue = rndrng_prov.Text },
new DataPair { Name = "AdmissionDate", OutputValue = admsn_date.Text }
};
this.FetchData();
}
private void FetchData()
{
Patient[] p = client.GetPatientsBySearchParams(dpair);
}
public Patient[] GetPatientsBySearchParams(DataPair[] dataPair)
{
P = lst_Patient.FindAll(
delegate(Patient tmp){
if(tmp.FirstName = dataPair[0].OutputValue || tmp.LastName = dataPair[1].OutputValue)
return true;
else
return false;
}
);
return P.ToArray();
}
You should use reflection to call the property whose name gets passed.
p.GetType().GetProperty(dataPair[i].Name).GetValue(p) == dataPair[i].OutputValue;

Categories

Resources